240 #ifndef NK_NUKLEAR_H_
241 #define NK_NUKLEAR_H_
253 #define NK_UNDEFINED (-1.0f)
254 #define NK_UTF_INVALID 0xFFFD
255 #define NK_UTF_SIZE 4
257 #define NK_INPUT_MAX 16
259 #ifndef NK_MAX_NUMBER_BUFFER
260 #define NK_MAX_NUMBER_BUFFER 64
262 #ifndef NK_SCROLLBAR_HIDING_TIMEOUT
263 #define NK_SCROLLBAR_HIDING_TIMEOUT 4.0f
274 #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199409L))
275 #define NK_API static inline
276 #elif defined(__cplusplus)
277 #define NK_API static inline
279 #define NK_API static
282 #define NK_API extern
286 #define NK_INTERN static
287 #define NK_STORAGE static
288 #define NK_GLOBAL static
290 #define NK_FLAG(x) (1 << (x))
291 #define NK_STRINGIFY(x) #x
292 #define NK_MACRO_STRINGIFY(x) NK_STRINGIFY(x)
293 #define NK_STRING_JOIN_IMMEDIATE(arg1, arg2) arg1 ## arg2
294 #define NK_STRING_JOIN_DELAY(arg1, arg2) NK_STRING_JOIN_IMMEDIATE(arg1, arg2)
295 #define NK_STRING_JOIN(arg1, arg2) NK_STRING_JOIN_DELAY(arg1, arg2)
298 #define NK_UNIQUE_NAME(name) NK_STRING_JOIN(name,__COUNTER__)
300 #define NK_UNIQUE_NAME(name) NK_STRING_JOIN(name,__LINE__)
303 #ifndef NK_STATIC_ASSERT
304 #define NK_STATIC_ASSERT(exp) typedef char NK_UNIQUE_NAME(_dummy_array)[(exp)?1:-1]
309 #define NK_FILE_LINE __FILE__ ":" NK_MACRO_STRINGIFY(__COUNTER__)
311 #define NK_FILE_LINE __FILE__ ":" NK_MACRO_STRINGIFY(__LINE__)
315 #define NK_MIN(a,b) ((a) < (b) ? (a) : (b))
316 #define NK_MAX(a,b) ((a) < (b) ? (b) : (a))
317 #define NK_CLAMP(i,v,x) (NK_MAX(NK_MIN(v,x), i))
325 #ifdef NK_INCLUDE_FIXED_TYPES
327 #define NK_INT8 int8_t
328 #define NK_UINT8 uint8_t
329 #define NK_INT16 int16_t
330 #define NK_UINT16 uint16_t
331 #define NK_INT32 int32_t
332 #define NK_UINT32 uint32_t
333 #define NK_SIZE_TYPE uintptr_t
334 #define NK_POINTER_TYPE uintptr_t
340 #define NK_UINT8 unsigned char
343 #define NK_INT16 signed short
346 #define NK_UINT16 unsigned short
349 #if defined(_MSC_VER)
350 #define NK_INT32 __int32
352 #define NK_INT32 signed int
356 #if defined(_MSC_VER)
357 #define NK_UINT32 unsigned __int32
359 #define NK_UINT32 unsigned int
363 #if defined(_WIN64) && defined(_MSC_VER)
364 #define NK_SIZE_TYPE unsigned __int64
365 #elif (defined(_WIN32) || defined(WIN32)) && defined(_MSC_VER)
366 #define NK_SIZE_TYPE unsigned __int32
367 #elif defined(__GNUC__) || defined(__clang__)
368 #if defined(__x86_64__) || defined(__ppc64__)
369 #define NK_SIZE_TYPE unsigned long
371 #define NK_SIZE_TYPE unsigned int
374 #define NK_SIZE_TYPE unsigned long
377 #ifndef NK_POINTER_TYPE
378 #if defined(_WIN64) && defined(_MSC_VER)
379 #define NK_POINTER_TYPE unsigned __int64
380 #elif (defined(_WIN32) || defined(WIN32)) && defined(_MSC_VER)
381 #define NK_POINTER_TYPE unsigned __int32
382 #elif defined(__GNUC__) || defined(__clang__)
383 #if defined(__x86_64__) || defined(__ppc64__)
384 #define NK_POINTER_TYPE unsigned long
386 #define NK_POINTER_TYPE unsigned int
389 #define NK_POINTER_TYPE unsigned long
429 struct nk_draw_command;
437 struct nk_draw_vertex_layout_element;
441 struct nk_style_slide;
540 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
600 #ifdef NK_INCLUDE_COMMAND_USERDATA
1011 #define nk_foreach(c, ctx) for((c) = nk__begin(ctx); (c) != 0; (c) = nk__next(ctx,c))
1012 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
1047 NK_API const struct nk_draw_command* nk__draw_next(
const struct nk_draw_command*,
const struct nk_buffer*,
const struct nk_context*);
1053 #define nk_draw_foreach(cmd,ctx, b) for((cmd)=nk__draw_begin(ctx, b); (cmd)!=0; (cmd)=nk__draw_next(cmd, b, ctx))
1694 #define nk_tree_push(ctx, type, title, state) nk_tree_push_hashed(ctx, type, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),__LINE__)
1695 #define nk_tree_push_id(ctx, type, title, state, id) nk_tree_push_hashed(ctx, type, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),id)
1697 #define nk_tree_image_push(ctx, type, img, title, state) nk_tree_image_push_hashed(ctx, type, img, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),__LINE__)
1698 #define nk_tree_image_push_id(ctx, type, img, title, state, id) nk_tree_image_push_hashed(ctx, type, img, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),id)
1763 #ifdef NK_INCLUDE_STANDARD_VARARGS
1770 NK_API void nk_value_uint(
struct nk_context*,
const char *prefix,
unsigned int);
1871 NK_API double nk_propertyd(
struct nk_context*,
const char *name,
double min,
double val,
double max,
double step,
float inc_per_pixel);
2193 NK_API const char*
nk_utf_at(
const char *buffer,
int length,
int index, nk_rune *unicode,
int *len);
2343 struct nk_user_font_glyph;
2346 struct nk_user_font_glyph *glyph,
2347 nk_rune codepoint, nk_rune next_codepoint);
2349 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
2350 struct nk_user_font_glyph {
2355 float width, height;
2369 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
2377 #ifdef NK_INCLUDE_FONT_BAKING
2378 enum nk_font_coord_type {
2383 struct nk_baked_font {
2386 float ascent, descent;
2388 nk_rune glyph_offset;
2390 nk_rune glyph_count;
2392 const nk_rune *ranges;
2396 struct nk_font_config {
2397 struct nk_font_config *next;
2406 unsigned char ttf_data_owned_by_atlas;
2408 unsigned char merge_mode;
2410 unsigned char pixel_snap;
2412 unsigned char oversample_v, oversample_h;
2414 unsigned char padding[3];
2418 enum nk_font_coord_type coord_type;
2422 const nk_rune *range;
2424 struct nk_baked_font *font;
2426 nk_rune fallback_glyph;
2430 struct nk_font_glyph {
2433 float x0, y0, x1, y1, w, h;
2434 float u0, v0, u1, v1;
2438 struct nk_font *next;
2440 struct nk_baked_font info;
2442 struct nk_font_glyph *glyphs;
2443 const struct nk_font_glyph *fallback;
2444 nk_rune fallback_codepoint;
2446 struct nk_font_config *
config;
2449 enum nk_font_atlas_format {
2450 NK_FONT_ATLAS_ALPHA8,
2451 NK_FONT_ATLAS_RGBA32
2454 struct nk_font_atlas {
2466 struct nk_font_glyph *glyphs;
2467 struct nk_font *default_font;
2468 struct nk_font *fonts;
2469 struct nk_font_config *
config;
2474 NK_API const nk_rune *nk_font_default_glyph_ranges(
void);
2475 NK_API const nk_rune *nk_font_chinese_glyph_ranges(
void);
2476 NK_API const nk_rune *nk_font_cyrillic_glyph_ranges(
void);
2477 NK_API const nk_rune *nk_font_korean_glyph_ranges(
void);
2479 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
2480 NK_API void nk_font_atlas_init_default(
struct nk_font_atlas*);
2484 NK_API void nk_font_atlas_begin(
struct nk_font_atlas*);
2485 NK_API struct nk_font_config nk_font_config(float pixel_height);
2486 NK_API struct nk_font *nk_font_atlas_add(
struct nk_font_atlas*,
const struct nk_font_config*);
2487 #ifdef NK_INCLUDE_DEFAULT_FONT
2488 NK_API struct nk_font* nk_font_atlas_add_default(
struct nk_font_atlas*,
float height,
const struct nk_font_config*);
2490 NK_API struct nk_font* nk_font_atlas_add_from_memory(
struct nk_font_atlas *atlas,
void *memory, nk_size size,
float height,
const struct nk_font_config *
config);
2491 #ifdef NK_INCLUDE_STANDARD_IO
2492 NK_API struct nk_font* nk_font_atlas_add_from_file(
struct nk_font_atlas *atlas,
const char *file_path,
float height,
const struct nk_font_config*);
2494 NK_API struct nk_font *nk_font_atlas_add_compressed(
struct nk_font_atlas*,
void *memory, nk_size size,
float height,
const struct nk_font_config*);
2495 NK_API struct nk_font* nk_font_atlas_add_compressed_base85(
struct nk_font_atlas*,
const char *data,
float height,
const struct nk_font_config *
config);
2496 NK_API const void* nk_font_atlas_bake(
struct nk_font_atlas*,
int *width,
int *height,
enum nk_font_atlas_format);
2498 NK_API const struct nk_font_glyph* nk_font_find_glyph(
struct nk_font*, nk_rune unicode);
2499 NK_API void nk_font_atlas_cleanup(
struct nk_font_atlas *atlas);
2500 NK_API void nk_font_atlas_clear(
struct nk_font_atlas*);
2584 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
2614 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
2683 #ifndef NK_TEXTEDIT_UNDOSTATECOUNT
2684 #define NK_TEXTEDIT_UNDOSTATECOUNT 99
2687 #ifndef NK_TEXTEDIT_UNDOCHARCOUNT
2688 #define NK_TEXTEDIT_UNDOCHARCOUNT 999
2755 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
2845 #ifdef NK_INCLUDE_COMMAND_USERDATA
2981 unsigned short w,
unsigned short h, nk_handle callback_data);
3017 NK_API void nk_stroke_curve(
struct nk_command_buffer*,
float,
float,
float,
float,
float,
float,
float,
float,
float line_thickness,
struct nk_color);
3096 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
3110 typedef nk_ushort nk_draw_index;
3111 enum nk_draw_list_stroke {
3118 enum nk_draw_vertex_layout_attribute {
3122 NK_VERTEX_ATTRIBUTE_COUNT
3125 enum nk_draw_vertex_layout_format {
3135 NK_FORMAT_COLOR_BEGIN,
3136 NK_FORMAT_R8G8B8 = NK_FORMAT_COLOR_BEGIN,
3137 NK_FORMAT_R16G15B16,
3138 NK_FORMAT_R32G32B32,
3141 NK_FORMAT_R16G15B16A16,
3142 NK_FORMAT_R32G32B32A32,
3143 NK_FORMAT_R32G32B32A32_FLOAT,
3144 NK_FORMAT_R32G32B32A32_DOUBLE,
3148 NK_FORMAT_COLOR_END = NK_FORMAT_RGBA32,
3152 #define NK_VERTEX_LAYOUT_END NK_VERTEX_ATTRIBUTE_COUNT,NK_FORMAT_COUNT,0
3153 struct nk_draw_vertex_layout_element {
3154 enum nk_draw_vertex_layout_attribute attribute;
3155 enum nk_draw_vertex_layout_format format;
3159 struct nk_draw_command {
3160 unsigned int elem_count;
3166 #ifdef NK_INCLUDE_COMMAND_USERDATA
3171 struct nk_draw_list {
3173 struct nk_vec2 circle_vtx[12];
3180 unsigned int element_count;
3181 unsigned int vertex_count;
3182 unsigned int cmd_count;
3185 unsigned int path_count;
3186 unsigned int path_offset;
3188 #ifdef NK_INCLUDE_COMMAND_USERDATA
3194 NK_API void nk_draw_list_init(
struct nk_draw_list*);
3196 NK_API void nk_draw_list_clear(
struct nk_draw_list*);
3199 #define nk_draw_list_foreach(cmd, can, b) for((cmd)=nk__draw_list_begin(can, b); (cmd)!=0; (cmd)=nk__draw_list_next(cmd, b, can))
3200 NK_API const struct nk_draw_command* nk__draw_list_begin(
const struct nk_draw_list*,
const struct nk_buffer*);
3201 NK_API const struct nk_draw_command* nk__draw_list_next(
const struct nk_draw_command*,
const struct nk_buffer*,
const struct nk_draw_list*);
3202 NK_API const struct nk_draw_command* nk__draw_list_end(
const struct nk_draw_list*,
const struct nk_buffer*);
3203 NK_API void nk_draw_list_clear(
struct nk_draw_list *list);
3206 NK_API void nk_draw_list_path_clear(
struct nk_draw_list*);
3207 NK_API void nk_draw_list_path_line_to(
struct nk_draw_list*,
struct nk_vec2 pos);
3208 NK_API void nk_draw_list_path_arc_to_fast(
struct nk_draw_list*,
struct nk_vec2 center,
float radius,
int a_min,
int a_max);
3209 NK_API void nk_draw_list_path_arc_to(
struct nk_draw_list*,
struct nk_vec2 center,
float radius,
float a_min,
float a_max,
unsigned int segments);
3210 NK_API void nk_draw_list_path_rect_to(
struct nk_draw_list*,
struct nk_vec2 a,
struct nk_vec2 b,
float rounding);
3211 NK_API void nk_draw_list_path_curve_to(
struct nk_draw_list*,
struct nk_vec2 p2,
struct nk_vec2 p3,
struct nk_vec2 p4,
unsigned int num_segments);
3212 NK_API void nk_draw_list_path_fill(
struct nk_draw_list*,
struct nk_color);
3213 NK_API void nk_draw_list_path_stroke(
struct nk_draw_list*,
struct nk_color,
enum nk_draw_list_stroke closed,
float thickness);
3217 NK_API void nk_draw_list_stroke_rect(
struct nk_draw_list*,
struct nk_rect rect,
struct nk_color,
float rounding,
float thickness);
3219 NK_API void nk_draw_list_stroke_circle(
struct nk_draw_list*,
struct nk_vec2 center,
float radius,
struct nk_color,
unsigned int segs,
float thickness);
3221 NK_API void nk_draw_list_stroke_poly_line(
struct nk_draw_list*,
const struct nk_vec2 *pnts,
const unsigned int cnt,
struct nk_color,
enum nk_draw_list_stroke,
float thickness,
enum nk_anti_aliasing);
3224 NK_API void nk_draw_list_fill_rect(
struct nk_draw_list*,
struct nk_rect rect,
struct nk_color,
float rounding);
3227 NK_API void nk_draw_list_fill_circle(
struct nk_draw_list*,
struct nk_vec2 center,
float radius,
struct nk_color col,
unsigned int segs);
3232 NK_API void nk_draw_list_add_text(
struct nk_draw_list*,
const struct nk_user_font*,
struct nk_rect,
const char *text,
int len,
float font_height,
struct nk_color);
3233 #ifdef NK_INCLUDE_COMMAND_USERDATA
3234 NK_API void nk_draw_list_push_userdata(
struct nk_draw_list*, nk_handle userdata);
3683 #ifndef NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS
3684 #define NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS 16
3686 #ifndef NK_CHART_MAX_SLOT
3687 #define NK_CHART_MAX_SLOT 4
3783 #ifndef NK_WINDOW_MAX_NAME
3784 #define NK_WINDOW_MAX_NAME 64
3897 #ifndef NK_BUTTON_BEHAVIOR_STACK_SIZE
3898 #define NK_BUTTON_BEHAVIOR_STACK_SIZE 8
3901 #ifndef NK_FONT_STACK_SIZE
3902 #define NK_FONT_STACK_SIZE 8
3905 #ifndef NK_STYLE_ITEM_STACK_SIZE
3906 #define NK_STYLE_ITEM_STACK_SIZE 16
3909 #ifndef NK_FLOAT_STACK_SIZE
3910 #define NK_FLOAT_STACK_SIZE 32
3913 #ifndef NK_VECTOR_STACK_SIZE
3914 #define NK_VECTOR_STACK_SIZE 16
3917 #ifndef NK_FLAGS_STACK_SIZE
3918 #define NK_FLAGS_STACK_SIZE 32
3921 #ifndef NK_COLOR_STACK_SIZE
3922 #define NK_COLOR_STACK_SIZE 32
3925 #define NK_CONFIGURATION_STACK_TYPE(prefix, name, type)\
3926 struct nk_config_stack_##name##_element {\
3927 prefix##_##type *address;\
3928 prefix##_##type old_value;\
3930 #define NK_CONFIG_STACK(type,size)\
3931 struct nk_config_stack_##type {\
3933 struct nk_config_stack_##type##_element elements[size];\
3936 #define nk_float float
3966 #define NK_VALUE_PAGE_CAPACITY \
3967 ((NK_MAX(sizeof(struct nk_window),sizeof(struct nk_panel)) / sizeof(nk_uint)) / 2)
4019 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
4020 struct nk_draw_list draw_list;
4022 #ifdef NK_INCLUDE_COMMAND_USERDATA
4049 #define NK_PI 3.141592654f
4050 #define NK_UTF_INVALID 0xFFFD
4051 #define NK_MAX_FLOAT_PRECISION 2
4053 #define NK_UNUSED(x) ((void)(x))
4054 #define NK_SATURATE(x) (NK_MAX(0, NK_MIN(1.0f, x)))
4055 #define NK_LEN(a) (sizeof(a)/sizeof(a)[0])
4056 #define NK_ABS(a) (((a) < 0) ? -(a) : (a))
4057 #define NK_BETWEEN(x, a, b) ((a) <= (x) && (x) < (b))
4058 #define NK_INBOX(px, py, x, y, w, h)\
4059 (NK_BETWEEN(px,x,x+w) && NK_BETWEEN(py,y,y+h))
4060 #define NK_INTERSECT(x0, y0, w0, h0, x1, y1, w1, h1) \
4061 (!(((x1 > (x0 + w0)) || ((x1 + w1) < x0) || (y1 > (y0 + h0)) || (y1 + h1) < y0)))
4062 #define NK_CONTAINS(x, y, w, h, bx, by, bw, bh)\
4063 (NK_INBOX(x,y, bx, by, bw, bh) && NK_INBOX(x+w,y+h, bx, by, bw, bh))
4065 #define nk_vec2_sub(a, b) nk_vec2((a).x - (b).x, (a).y - (b).y)
4066 #define nk_vec2_add(a, b) nk_vec2((a).x + (b).x, (a).y + (b).y)
4067 #define nk_vec2_len_sqr(a) ((a).x*(a).x+(a).y*(a).y)
4068 #define nk_vec2_muls(a, t) nk_vec2((a).x * (t), (a).y * (t))
4070 #define nk_ptr_add(t, p, i) ((t*)((void*)((nk_byte*)(p) + (i))))
4071 #define nk_ptr_add_const(t, p, i) ((const t*)((const void*)((const nk_byte*)(p) + (i))))
4072 #define nk_zero_struct(s) nk_zero(&s, sizeof(s))
4078 #if defined(__PTRDIFF_TYPE__)
4079 # define NK_UINT_TO_PTR(x) ((void*)(__PTRDIFF_TYPE__)(x))
4080 # define NK_PTR_TO_UINT(x) ((nk_size)(__PTRDIFF_TYPE__)(x))
4081 #elif !defined(__GNUC__)
4082 # define NK_UINT_TO_PTR(x) ((void*)&((char*)0)[x])
4083 # define NK_PTR_TO_UINT(x) ((nk_size)(((char*)x)-(char*)0))
4084 #elif defined(NK_USE_FIXED_TYPES)
4085 # define NK_UINT_TO_PTR(x) ((void*)(uintptr_t)(x))
4086 # define NK_PTR_TO_UINT(x) ((uintptr_t)(x))
4088 # define NK_UINT_TO_PTR(x) ((void*)(x))
4089 # define NK_PTR_TO_UINT(x) ((nk_size)(x))
4092 #define NK_ALIGN_PTR(x, mask)\
4093 (NK_UINT_TO_PTR((NK_PTR_TO_UINT((nk_byte*)(x) + (mask-1)) & ~(mask-1))))
4094 #define NK_ALIGN_PTR_BACK(x, mask)\
4095 (NK_UINT_TO_PTR((NK_PTR_TO_UINT((nk_byte*)(x)) & ~(mask-1))))
4097 #define NK_OFFSETOF(st,m) ((nk_ptr)&(((st*)0)->m))
4098 #define NK_CONTAINER_OF(ptr,type,member)\
4099 (type*)((void*)((char*)(1 ? (ptr): &((type*)0)->member) - NK_OFFSETOF(type, member)))
4106 template<
typename T>
struct nk_alignof;
4107 template<
typename T,
int size_diff>
struct nk_helper{
enum {
value = size_diff};};
4109 template<
typename T>
struct nk_alignof{
struct Big {T x;
char c;};
enum {
4111 #define NK_ALIGNOF(t) (nk_alignof<t>::value);
4112 #elif defined(_MSC_VER)
4113 #define NK_ALIGNOF(t) (__alignof(t))
4115 #define NK_ALIGNOF(t) ((char*)(&((struct {char c; t _h;}*)0)->_h) - (char*)0)
4126 #ifdef NK_IMPLEMENTATION
4128 #ifndef NK_POOL_DEFAULT_CAPACITY
4129 #define NK_POOL_DEFAULT_CAPACITY 16
4132 #ifndef NK_DEFAULT_COMMAND_BUFFER_SIZE
4133 #define NK_DEFAULT_COMMAND_BUFFER_SIZE (4*1024)
4136 #ifndef NK_BUFFER_DEFAULT_INITIAL_SIZE
4137 #define NK_BUFFER_DEFAULT_INITIAL_SIZE (4*1024)
4141 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
4144 #ifdef NK_INCLUDE_STANDARD_IO
4147 #ifdef NK_INCLUDE_STANDARD_VARARGS
4152 #define NK_ASSERT(expr) assert(expr)
4156 #define NK_MEMSET nk_memset
4159 #define NK_MEMCPY nk_memcopy
4162 #define NK_SQRT nk_sqrt
4165 #define NK_SIN nk_sin
4168 #define NK_COS nk_cos
4171 #define NK_STRTOD nk_strtod
4174 #define NK_DTOA nk_dtoa
4177 #define NK_DEFAULT (-1)
4179 #ifndef NK_VSNPRINTF
4184 #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) ||\
4185 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
4186 (defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L)) ||\
4187 (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)) ||\
4188 defined(_ISOC99_SOURCE) || defined(_BSD_SOURCE)
4189 #define NK_VSNPRINTF(s,n,f,a) vsnprintf(s,n,f,a)
4191 #define NK_VSNPRINTF(s,n,f,a) vsprintf(s,f,a)
4195 #define NK_SCHAR_MIN (-127)
4196 #define NK_SCHAR_MAX 127
4197 #define NK_UCHAR_MIN 0
4198 #define NK_UCHAR_MAX 256
4199 #define NK_SSHORT_MIN (-32767)
4200 #define NK_SSHORT_MAX 32767
4201 #define NK_USHORT_MIN 0
4202 #define NK_USHORT_MAX 65535
4203 #define NK_SINT_MIN (-2147483647)
4204 #define NK_SINT_MAX 2147483647
4205 #define NK_UINT_MIN 0
4206 #define NK_UINT_MAX 4294967295u
4221 NK_GLOBAL const struct nk_rect nk_null_rect = {-8192.0f, -8192.0f, 16384, 16384};
4222 #define NK_FLOAT_PRECISION 0.00000000000001
4266 nk_inv_sqrt(
float number)
4269 const float threehalfs = 1.5f;
4270 union {nk_uint i;
float f;} conv = {0};
4273 conv.i = 0x5f375A84 - (conv.i >> 1);
4274 conv.f = conv.f * (threehalfs - (x2 * conv.f * conv.f));
4281 return x * nk_inv_sqrt(x);
4287 NK_STORAGE const float a0 = +1.91059300966915117e-31f;
4288 NK_STORAGE const float a1 = +1.00086760103908896f;
4289 NK_STORAGE const float a2 = -1.21276126894734565e-2f;
4290 NK_STORAGE const float a3 = -1.38078780785773762e-1f;
4291 NK_STORAGE const float a4 = -2.67353392911981221e-2f;
4292 NK_STORAGE const float a5 = +2.08026600266304389e-2f;
4293 NK_STORAGE const float a6 = -3.03996055049204407e-3f;
4294 NK_STORAGE const float a7 = +1.38235642404333740e-4f;
4295 return a0 + x*(a1 + x*(a2 + x*(a3 + x*(a4 + x*(a5 + x*(a6 + x*a7))))));
4301 NK_STORAGE const float a0 = +1.00238601909309722f;
4302 NK_STORAGE const float a1 = -3.81919947353040024e-2f;
4303 NK_STORAGE const float a2 = -3.94382342128062756e-1f;
4304 NK_STORAGE const float a3 = -1.18134036025221444e-1f;
4305 NK_STORAGE const float a4 = +1.07123798512170878e-1f;
4306 NK_STORAGE const float a5 = -1.86637164165180873e-2f;
4307 NK_STORAGE const float a6 = +9.90140908664079833e-4f;
4308 NK_STORAGE const float a7 = -5.23022132118824778e-14f;
4309 return a0 + x*(a1 + x*(a2 + x*(a3 + x*(a4 + x*(a5 + x*(a6 + x*a7))))));
4313 nk_round_up_pow2(nk_uint v)
4328 return nk_null_rect;
4354 return nk_rect(pos.x, pos.y, size.x, size.y);
4360 return nk_rect(r[0], r[1], r[2], r[3]);
4366 return nk_recti(r[0], r[1], r[2], r[3]);
4373 ret.
x = r.x; ret.y = r.y;
4381 ret.
x = r.w; ret.y = r.h;
4386 nk_shrink_rect(struct
nk_rect r, float amount)
4389 r.
w =
NK_MAX(r.w, 2 * amount);
4390 r.h =
NK_MAX(r.h, 2 * amount);
4391 res.x = r.x + amount;
4392 res.y = r.y + amount;
4393 res.w = r.w - 2 * amount;
4394 res.h = r.h - 2 * amount;
4402 r.h =
NK_MAX(r.h, 2 * pad.y);
4403 r.x += pad.x; r.y += pad.y;
4413 ret.
x =
x; ret.y =
y;
4445 NK_INTERN int nk_str_match_here(
const char *regexp,
const char *text);
4446 NK_INTERN int nk_str_match_star(
int c,
const char *regexp,
const char *text);
4447 NK_INTERN int nk_is_lower(
int c) {
return (c >=
'a' && c <=
'z') || (c >= 0xE0 && c <= 0xFF);}
4448 NK_INTERN int nk_is_upper(
int c){
return (c >=
'A' && c <=
'Z') || (c >= 0xC0 && c <= 0xDF);}
4449 NK_INTERN int nk_to_upper(
int c) {
return (c >=
'a' && c <=
'z') ? (c - (
'a' -
'A')) : c;}
4450 NK_INTERN int nk_to_lower(
int c) {
return (c >=
'A' && c <=
'Z') ? (c - (
'a' +
'A')) : c;}
4453 nk_memcopy(
void *dst0,
const void *src0, nk_size length)
4456 char *dst = (
char*)dst0;
4457 const char *src = (
const char*)src0;
4458 if (length == 0 || dst == src)
4462 #define nk_wsize sizeof(nk_word)
4463 #define nk_wmask (nk_wsize-1)
4464 #define NK_TLOOP(s) if (t) NK_TLOOP1(s)
4465 #define NK_TLOOP1(s) do { s; } while (--t)
4469 if ((t | (nk_ptr)dst) & nk_wmask) {
4470 if ((t ^ (nk_ptr)dst) & nk_wmask || length < nk_wsize)
4473 t = nk_wsize - (t & nk_wmask);
4475 NK_TLOOP1(*dst++ = *src++);
4477 t = length / nk_wsize;
4478 NK_TLOOP(*(nk_word*)(
void*)dst = *(
const nk_word*)(
const void*)src;
4479 src += nk_wsize; dst += nk_wsize);
4480 t = length & nk_wmask;
4481 NK_TLOOP(*dst++ = *src++);
4486 if ((t | (nk_ptr)dst) & nk_wmask) {
4487 if ((t ^ (nk_ptr)dst) & nk_wmask || length <= nk_wsize)
4492 NK_TLOOP1(*--dst = *--src);
4494 t = length / nk_wsize;
4495 NK_TLOOP(src -= nk_wsize; dst -= nk_wsize;
4496 *(nk_word*)(
void*)dst = *(
const nk_word*)(
const void*)src);
4497 t = length & nk_wmask;
4498 NK_TLOOP(*--dst = *--src);
4510 nk_memset(
void *ptr,
int c0, nk_size size)
4512 #define nk_word unsigned
4513 #define nk_wsize sizeof(nk_word)
4514 #define nk_wmask (nk_wsize - 1)
4515 nk_byte *dst = (nk_byte*)ptr;
4519 if ((c = (nk_byte)c0) != 0) {
4521 if (
sizeof(
unsigned int) > 2)
4526 dst = (nk_byte*)ptr;
4527 if (size < 3 * nk_wsize) {
4528 while (size--) *dst++ = (
nk_byte)c0;
4542 t = size / nk_wsize;
4544 *(nk_word*)((
void*)dst) = c;
4549 t = (size & nk_wmask);
4562 nk_zero(
void *ptr, nk_size size)
4565 NK_MEMSET(ptr, 0, size);
4573 while (str && *str++ !=
'\0') siz++;
4578 nk_strtoi(
const char *str,
const char **endptr)
4581 const char *p = str;
4588 while (*p ==
' ') p++;
4593 while (*p && *p >=
'0' && *p <=
'9') {
4594 value = value * 10 + (
int) (*p -
'0');
4603 nk_strtod(
const char *str,
const char **endptr)
4607 const char *p = str;
4615 while (*p ==
' ') p++;
4621 while (*p && *p !=
'.' && *p !=
'e') {
4622 value = value * 10.0 + (double) (*p -
'0');
4628 for(m = 0.1; *p && *p !=
'e'; p++ ) {
4629 value = value + (double) (*p -
'0') *
m;
4639 }
else if (*p ==
'+') {
4644 for (pow = 0; *p; p++)
4645 pow = pow * 10 + (
int) (*p -
'0');
4647 for (m = 1.0, i = 0; i < pow; i++)
4654 number = value * neg;
4661 nk_strtof(
const char *str,
const char **endptr)
4664 double double_value;
4665 double_value = NK_STRTOD(str, endptr);
4666 float_value = (float)double_value;
4679 if (c1 <= 'Z' && c1 >=
'A') {
4683 if (c2 <= 'Z' && c2 >=
'A') {
4687 return ((d >= 0) << 1) - 1;
4694 nk_stricmpn(
const char *s1,
const char *s2,
int n)
4705 if (c1 <= 'Z' && c1 >=
'A') {
4709 if (c2 <= 'Z' && c2 >=
'A') {
4713 return ((d >= 0) << 1) - 1;
4720 nk_str_match_here(
const char *regexp,
const char *text)
4722 if (regexp[0] ==
'\0')
4724 if (regexp[1] ==
'*')
4725 return nk_str_match_star(regexp[0], regexp+2, text);
4726 if (regexp[0] ==
'$' && regexp[1] ==
'\0')
4727 return *text ==
'\0';
4728 if (*text!=
'\0' && (regexp[0]==
'.' || regexp[0]==*text))
4729 return nk_str_match_here(regexp+1, text+1);
4734 nk_str_match_star(
int c,
const char *regexp,
const char *text)
4737 if (nk_str_match_here(regexp, text))
4739 }
while (*text !=
'\0' && (*text++ == c || c ==
'.'));
4752 if (regexp[0] ==
'^')
4753 return nk_str_match_here(regexp+1, text);
4755 if (nk_str_match_here(regexp, text))
4757 }
while (*text++ !=
'\0');
4763 const char *pattern,
int *out_score)
4771 #define NK_ADJACENCY_BONUS 5
4773 #define NK_SEPARATOR_BONUS 10
4775 #define NK_CAMEL_BONUS 10
4777 #define NK_LEADING_LETTER_PENALTY (-3)
4779 #define NK_MAX_LEADING_LETTER_PENALTY (-9)
4781 #define NK_UNMATCHED_LETTER_PENALTY (-1)
4785 char const * pattern_iter = pattern;
4793 char const * best_letter = 0;
4794 int best_letter_score = 0;
4799 if (!str || !str_len || !pattern)
return 0;
4800 while (str_iter < str_len)
4802 const char pattern_letter = *pattern_iter;
4803 const char str_letter = str[str_iter];
4805 int next_match = *pattern_iter !=
'\0' &&
4806 nk_to_lower(pattern_letter) == nk_to_lower(str_letter);
4807 int rematch = best_letter && nk_to_upper(*best_letter) == nk_to_upper(str_letter);
4809 int advanced = next_match && best_letter;
4810 int pattern_repeat = best_letter && *pattern_iter !=
'\0';
4811 pattern_repeat = pattern_repeat &&
4812 nk_to_lower(*best_letter) == nk_to_lower(pattern_letter);
4814 if (advanced || pattern_repeat) {
4815 score += best_letter_score;
4817 best_letter_score = 0;
4820 if (next_match || rematch)
4824 if (pattern_iter == pattern) {
4825 int count = (
int)(&str[str_iter] - str);
4826 int penalty = NK_LEADING_LETTER_PENALTY * count;
4827 if (penalty < NK_MAX_LEADING_LETTER_PENALTY)
4828 penalty = NK_MAX_LEADING_LETTER_PENALTY;
4835 new_score += NK_ADJACENCY_BONUS;
4839 new_score += NK_SEPARATOR_BONUS;
4842 if (prev_lower && nk_is_upper(str_letter))
4843 new_score += NK_CAMEL_BONUS;
4850 if (new_score >= best_letter_score) {
4852 if (best_letter != 0)
4853 score += NK_UNMATCHED_LETTER_PENALTY;
4855 best_letter = &str[str_iter];
4856 best_letter_score = new_score;
4860 score += NK_UNMATCHED_LETTER_PENALTY;
4865 prev_lower = nk_is_lower(str_letter) != 0;
4866 prev_separator = str_letter ==
'_' || str_letter ==
' ';
4873 score += best_letter_score;
4876 if (*pattern_iter !=
'\0')
4889 nk_string_float_limit(
char *
string,
int prec)
4899 if (dot == (prec+1)) {
4906 return (
int)(c -
string);
4910 nk_pow(
double x,
int n)
4915 n = (plus) ? n : -n;
4922 return plus ? r : 1.0 / r;
4926 nk_ifloord(
double x)
4928 x = (double)((
int)x - ((x < 0.0) ? 1 : 0));
4935 x = (float)((
int)x - ((x < 0.0f) ? 1 : 0));
4947 float r = x - (float)t;
4948 return (r > 0.0f) ? t+1: t;
4959 neg = (n < 0) ? 1 : 0;
4960 ret = (neg) ? (
int)-n : (
int)n;
4961 while ((ret / 10) > 0) {
4965 if (neg) exp = -exp;
4970 nk_strrev_ascii(
char *s)
4976 for (; i < end; ++i) {
4978 s[i] = s[len - 1 - i];
4984 nk_itoa(
char *s,
long n)
4997 s[i++] = (char)(
'0' + (n % 10));
5009 nk_dtoa(
char *s,
double n)
5012 int digit = 0, m = 0, m1 = 0;
5020 s[0] =
'0'; s[1] =
'\0';
5029 useExp = (m >= 14 || (neg && m >= 9) || m <= -9);
5030 if (neg) *(c++) =
'-';
5036 n = n / (double)nk_pow(10.0, m);
5045 while (n > NK_FLOAT_PRECISION || m >= 0) {
5046 double weight = nk_pow(10.0, m);
5048 double t = (double)n / weight;
5049 digit = nk_ifloord(t);
5050 n -= ((double)digit * weight);
5051 *(c++) = (
char)(
'0' + (char)digit);
5053 if (m == 0 && n > 0)
5070 *(c++) = (
char)(
'0' + (char)(m1 % 10));
5075 for (i = 0, j = m-1; i<j; i++, j--) {
5087 #ifdef NK_INCLUDE_STANDARD_VARARGS
5088 #ifndef NK_INCLUDE_STANDARD_IO
5090 nk_vsnprintf(
char *buf,
int buf_size,
const char *fmt, va_list args)
5095 NK_ARG_TYPE_DEFAULT,
5099 NK_ARG_FLAG_LEFT = 0x01,
5100 NK_ARG_FLAG_PLUS = 0x02,
5101 NK_ARG_FLAG_SPACE = 0x04,
5102 NK_ARG_FLAG_NUM = 0x10,
5103 NK_ARG_FLAG_ZERO = 0x20
5107 enum nk_arg_type arg_type = NK_ARG_TYPE_DEFAULT;
5108 int precision = NK_DEFAULT;
5109 int width = NK_DEFAULT;
5114 const char *iter = fmt;
5117 NK_ASSERT(buf_size);
5118 if (!buf || !buf_size || !fmt)
return 0;
5119 for (iter = fmt; *iter && len < buf_size; iter++) {
5121 while (*iter && (*iter !=
'%') && (len < buf_size))
5122 buf[len++] = *iter++;
5123 if (!(*iter) || len >= buf_size)
break;
5128 if (*iter ==
'-') flag |= NK_ARG_FLAG_LEFT;
5129 else if (*iter ==
'+') flag |= NK_ARG_FLAG_PLUS;
5130 else if (*iter ==
' ') flag |= NK_ARG_FLAG_SPACE;
5131 else if (*iter ==
'#') flag |= NK_ARG_FLAG_NUM;
5132 else if (*iter ==
'0') flag |= NK_ARG_FLAG_ZERO;
5139 if (*iter >=
'1' && *iter <=
'9') {
5145 }
else if (*iter ==
'*') {
5146 width = va_arg(args,
int);
5151 precision = NK_DEFAULT;
5155 precision = va_arg(args,
int);
5168 if (*(iter+1) ==
'h') {
5169 arg_type = NK_ARG_TYPE_CHAR;
5171 }
else arg_type = NK_ARG_TYPE_SHORT;
5173 }
else if (*iter ==
'l') {
5174 arg_type = NK_ARG_TYPE_LONG;
5176 }
else arg_type = NK_ARG_TYPE_DEFAULT;
5180 NK_ASSERT(arg_type == NK_ARG_TYPE_DEFAULT);
5181 NK_ASSERT(precision == NK_DEFAULT);
5182 NK_ASSERT(width == NK_DEFAULT);
5185 }
else if (*iter ==
's') {
5187 const char *str = va_arg(args,
const char*);
5188 NK_ASSERT(str != buf &&
"buffer and argument are not allowed to overlap!");
5189 NK_ASSERT(arg_type == NK_ARG_TYPE_DEFAULT);
5190 NK_ASSERT(precision == NK_DEFAULT);
5191 NK_ASSERT(width == NK_DEFAULT);
5192 if (str == buf)
return -1;
5193 while (str && *str && len < buf_size)
5194 buf[len++] = *str++;
5195 }
else if (*iter ==
'n') {
5197 signed int *n = va_arg(args,
int*);
5198 NK_ASSERT(arg_type == NK_ARG_TYPE_DEFAULT);
5199 NK_ASSERT(precision == NK_DEFAULT);
5200 NK_ASSERT(width == NK_DEFAULT);
5202 }
else if (*iter ==
'c' || *iter ==
'i' || *iter ==
'd') {
5205 const char *num_iter;
5206 int num_len, num_print, padding;
5207 int cur_precision =
NK_MAX(precision, 1);
5208 int cur_width =
NK_MAX(width, 0);
5211 if (arg_type == NK_ARG_TYPE_CHAR)
5212 value = (
signed char)va_arg(args,
int);
5213 else if (arg_type == NK_ARG_TYPE_SHORT)
5214 value = (
signed short)va_arg(args,
int);
5215 else if (arg_type == NK_ARG_TYPE_LONG)
5216 value = va_arg(args,
signed long);
5217 else if (*iter ==
'c')
5218 value = (
unsigned char)va_arg(args,
int);
5219 else value = va_arg(args,
signed int);
5222 nk_itoa(number_buffer, value);
5224 padding =
NK_MAX(cur_width -
NK_MAX(cur_precision, num_len), 0);
5225 if ((flag & NK_ARG_FLAG_PLUS) || (flag & NK_ARG_FLAG_SPACE))
5226 padding =
NK_MAX(padding-1, 0);
5229 if (!(flag & NK_ARG_FLAG_LEFT)) {
5230 while (padding-- > 0 && (len < buf_size)) {
5231 if ((flag & NK_ARG_FLAG_ZERO) && (precision == NK_DEFAULT))
5233 else buf[len++] =
' ';
5238 if ((flag & NK_ARG_FLAG_PLUS) && value >= 0 && len < buf_size)
5240 else if ((flag & NK_ARG_FLAG_SPACE) && value >= 0 && len < buf_size)
5244 num_print =
NK_MAX(cur_precision, num_len);
5245 while (precision && (num_print > num_len) && (len < buf_size)) {
5251 num_iter = number_buffer;
5252 while (precision && *num_iter && len < buf_size)
5253 buf[len++] = *num_iter++;
5256 if (flag & NK_ARG_FLAG_LEFT) {
5257 while ((padding-- > 0) && (len < buf_size))
5260 }
else if (*iter ==
'o' || *iter ==
'x' || *iter ==
'X' || *iter ==
'u') {
5262 unsigned long value = 0;
5263 int num_len = 0, num_print, padding = 0;
5264 int cur_precision =
NK_MAX(precision, 1);
5265 int cur_width =
NK_MAX(width, 0);
5266 unsigned int base = (*iter ==
'o') ? 8: (*iter ==
'u')? 10: 16;
5269 const char *upper_output_format =
"0123456789ABCDEF";
5270 const char *lower_output_format =
"0123456789abcdef";
5271 const char *output_format = (*iter ==
'x') ?
5272 lower_output_format: upper_output_format;
5275 if (arg_type == NK_ARG_TYPE_CHAR)
5276 value = (
unsigned char)va_arg(args,
int);
5277 else if (arg_type == NK_ARG_TYPE_SHORT)
5278 value = (
unsigned short)va_arg(args,
int);
5279 else if (arg_type == NK_ARG_TYPE_LONG)
5280 value = va_arg(args,
unsigned long);
5281 else value = va_arg(args,
unsigned int);
5285 int digit = output_format[value % base];
5287 number_buffer[num_len++] = (char)digit;
5289 }
while (value > 0);
5291 num_print =
NK_MAX(cur_precision, num_len);
5292 padding =
NK_MAX(cur_width -
NK_MAX(cur_precision, num_len), 0);
5293 if (flag & NK_ARG_FLAG_NUM)
5294 padding =
NK_MAX(padding-1, 0);
5297 if (!(flag & NK_ARG_FLAG_LEFT)) {
5298 while ((padding-- > 0) && (len < buf_size)) {
5299 if ((flag & NK_ARG_FLAG_ZERO) && (precision == NK_DEFAULT))
5301 else buf[len++] =
' ';
5306 if (num_print && (flag & NK_ARG_FLAG_NUM)) {
5307 if ((*iter ==
'o') && (len < buf_size)) {
5309 }
else if ((*iter ==
'x') && ((len+1) < buf_size)) {
5312 }
else if ((*iter ==
'X') && ((len+1) < buf_size)) {
5317 while (precision && (num_print > num_len) && (len < buf_size)) {
5323 while (num_len > 0) {
5324 if (precision && (len < buf_size))
5325 buf[len++] = number_buffer[num_len-1];
5330 if (flag & NK_ARG_FLAG_LEFT) {
5331 while ((padding-- > 0) && (len < buf_size))
5334 }
else if (*iter ==
'f') {
5336 const char *num_iter;
5337 int cur_precision = (precision < 0) ? 6: precision;
5338 int prefix, cur_width =
NK_MAX(width, 0);
5339 double value = va_arg(args,
double);
5340 int num_len = 0, frac_len = 0, dot = 0;
5343 NK_ASSERT(arg_type == NK_ARG_TYPE_DEFAULT);
5344 NK_DTOA(number_buffer, value);
5348 num_iter = number_buffer;
5349 while (*num_iter && *num_iter !=
'.')
5352 prefix = (*num_iter ==
'.')?(
int)(num_iter - number_buffer)+1:0;
5353 padding =
NK_MAX(cur_width - (prefix +
NK_MIN(cur_precision, num_len - prefix)) , 0);
5354 if ((flag & NK_ARG_FLAG_PLUS) || (flag & NK_ARG_FLAG_SPACE))
5355 padding =
NK_MAX(padding-1, 0);
5358 if (!(flag & NK_ARG_FLAG_LEFT)) {
5359 while (padding-- > 0 && (len < buf_size)) {
5360 if (flag & NK_ARG_FLAG_ZERO)
5362 else buf[len++] =
' ';
5367 num_iter = number_buffer;
5368 if ((flag & NK_ARG_FLAG_PLUS) && (value >= 0) && (len < buf_size))
5370 else if ((flag & NK_ARG_FLAG_SPACE) && (value >= 0) && (len < buf_size))
5373 if (dot) frac_len++;
5375 buf[len++] = *num_iter;
5376 if (*num_iter ==
'.') dot = 1;
5377 if (frac_len >= cur_precision)
break;
5382 while (frac_len < cur_precision) {
5383 if (!dot && len < buf_size) {
5393 if (flag & NK_ARG_FLAG_LEFT) {
5394 while ((padding-- > 0) && (len < buf_size))
5399 NK_ASSERT(0 &&
"specifier is not supported!");
5403 buf[(len >= buf_size)?(buf_size-1):len] = 0;
5404 result = (len >= buf_size)?-1:len;
5410 nk_strfmt(
char *buf,
int buf_size,
const char *fmt, va_list args)
5414 NK_ASSERT(buf_size);
5415 if (!buf || !buf_size || !fmt)
return 0;
5416 #ifdef NK_INCLUDE_STANDARD_IO
5417 result = NK_VSNPRINTF(buf, (nk_size)buf_size, fmt, args);
5418 result = (result >= buf_size) ? -1: result;
5419 buf[buf_size-1] = 0;
5421 result = nk_vsnprintf(buf, buf_size, fmt, args);
5431 #define NK_ROTL(x,r) ((x) << (r) | ((x) >> (32 - r)))
5432 union {
const nk_uint *i;
const nk_byte *b;} conv = {0};
5433 const nk_byte *data = (
const nk_byte*)key;
5434 const int nblocks = len/4;
5436 const nk_uint c1 = 0xcc9e2d51;
5437 const nk_uint c2 = 0x1b873593;
5438 const nk_byte *tail;
5439 const nk_uint *blocks;
5445 conv.b = (data + nblocks*4);
5446 blocks = (
const nk_uint*)conv.i;
5447 for (i = -nblocks; i; ++i) {
5450 k1 = NK_ROTL(k1,15);
5454 h1 = NK_ROTL(h1,13);
5455 h1 = h1*5+0xe6546b64;
5459 tail = (
const nk_byte*)(data + nblocks*4);
5462 case 3: k1 ^= (
nk_uint)(tail[2] << 16);
5463 case 2: k1 ^= (
nk_uint)(tail[1] << 8u);
5464 case 1: k1 ^= tail[0];
5466 k1 = NK_ROTL(k1,15);
5485 #ifdef NK_INCLUDE_STANDARD_IO
5487 nk_file_load(
const char* path, nk_size* siz,
struct nk_allocator *alloc)
5496 if (!path || !siz || !alloc)
5499 fd = fopen(path,
"rb");
5515 *siz = (
nk_size)fread(buf, *siz, 1, fd);
5529 nk_parse_hex(
const char *p,
int length)
5533 while (len < length) {
5535 if (p[len] >=
'a' && p[len] <=
'f')
5536 i += ((p[len] -
'a') + 10);
5537 else if (p[len] >=
'A' && p[len] <=
'F')
5538 i += ((p[len] -
'A') + 10);
5539 else i += (p[len] -
'0');
5560 const char *c = rgb;
5562 col.
r = (
nk_byte)nk_parse_hex(c, 2);
5563 col.g = (
nk_byte)nk_parse_hex(c+2, 2);
5564 col.b = (
nk_byte)nk_parse_hex(c+4, 2);
5573 const char *c = rgb;
5575 col.
r = (
nk_byte)nk_parse_hex(c, 2);
5576 col.g = (
nk_byte)nk_parse_hex(c+2, 2);
5577 col.b = (
nk_byte)nk_parse_hex(c+4, 2);
5578 col.a = (
nk_byte)nk_parse_hex(c+6, 2);
5585 #define NK_TO_HEX(i) ((i) <= 9 ? '0' + (i): 'A' - 10 + (i))
5586 output[0] = (char)NK_TO_HEX((col.
r & 0xF0) >> 4);
5587 output[1] = (char)NK_TO_HEX((col.
r & 0x0F));
5588 output[2] = (char)NK_TO_HEX((col.
g & 0xF0) >> 4);
5589 output[3] = (char)NK_TO_HEX((col.
g & 0x0F));
5590 output[4] = (char)NK_TO_HEX((col.
b & 0xF0) >> 4);
5591 output[5] = (char)NK_TO_HEX((col.
b & 0x0F));
5592 output[6] = (char)NK_TO_HEX((col.
a & 0xF0) >> 4);
5593 output[7] = (char)NK_TO_HEX((col.
a & 0x0F));
5601 #define NK_TO_HEX(i) ((i) <= 9 ? '0' + (i): 'A' - 10 + (i))
5602 output[0] = (char)NK_TO_HEX((col.
r & 0xF0) >> 4);
5603 output[1] = (char)NK_TO_HEX((col.
r & 0x0F));
5604 output[2] = (char)NK_TO_HEX((col.
g & 0xF0) >> 4);
5605 output[3] = (char)NK_TO_HEX((col.
g & 0x0F));
5606 output[4] = (char)NK_TO_HEX((col.
b & 0xF0) >> 4);
5607 output[5] = (char)NK_TO_HEX((col.
b & 0x0F));
5615 return nk_rgba(c[0], c[1], c[2], c[3]);
5621 return nk_rgba(c[0], c[1], c[2], c[3]);
5638 return nk_rgb(c[0], c[1], c[2]);
5644 return nk_rgb(c[0], c[1], c[2]);
5651 ret.
r = (in & 0xFF);
5652 ret.g = ((in >> 8) & 0xFF);
5653 ret.b = ((in >> 16) & 0xFF);
5654 ret.a = (
nk_byte)((in >> 24) & 0xFF);
5672 return nk_rgba_f(c[0], c[1], c[2], c[3]);
5693 nk_hsv(int h, int s, int v)
5701 return nk_hsv(c[0], c[1], c[2]);
5707 return nk_hsv(c[0], c[1], c[2]);
5711 nk_hsv_f(float h, float s, float v)
5723 nk_hsva(int h, int s, int v, int
a)
5725 float hf = ((float)
NK_CLAMP(0, h, 255)) / 255.0f;
5726 float sf = ((float)
NK_CLAMP(0, s, 255)) / 255.0f;
5727 float vf = ((float)
NK_CLAMP(0, v, 255)) / 255.0f;
5728 float af = ((float)
NK_CLAMP(0,
a, 255)) / 255.0f;
5735 return nk_hsva(c[0], c[1], c[2], c[3]);
5741 return nk_hsva(c[0], c[1], c[2], c[3]);
5745 nk_hsva_f(float h, float s, float v, float
a)
5752 out.
r = v; out.
g = v; out.
b = v;
5756 h = h / (60.0f/360.0f);
5760 q = v * (1.0f - (s * f));
5761 t = v * (1.0f - s * (1.0f - f));
5764 case 0:
default: out.r = v; out.g = t; out.b = p;
break;
5765 case 1: out.r = q; out.g = v; out.b = p;
break;
5766 case 2: out.r = p; out.g = v; out.b = t;
break;
5767 case 3: out.r = p; out.g = q; out.b = v;
break;
5768 case 4: out.r = t; out.g = p; out.b = v;
break;
5769 case 5: out.r = v; out.g = p; out.b = q;
break;
5777 return nk_hsva_f(c[0], c[1], c[2], c[3]);
5784 out |= ((nk_uint)in.
g << 8);
5794 *r = (float)in.
r * s;
5795 *g = (
float)in.
g * s;
5796 *b = (float)in.
b * s;
5797 *a = (
float)in.
a * s;
5810 *r = (double)in.
r * s;
5811 *g = (
double)in.
g * s;
5812 *b = (double)in.
b * s;
5813 *a = (
double)in.
a * s;
5838 float *out_v,
float *out_a,
struct nk_color in)
5846 const float t =
g; g =
b; b = t;
5850 const float t =
r; r =
g; g = t;
5853 chroma = r - ((g <
b) ? g: b);
5854 *out_h =
NK_ABS(K + (g - b)/(6.0f * chroma + 1e-20f));
5855 *out_s = chroma / (r + 1e-20f);
5857 *out_a = (float)in.
a / 255.0f;
5872 *out_h = (
nk_byte)(h * 255.0f);
5873 *out_s = (
nk_byte)(s * 255.0f);
5874 *out_v = (
nk_byte)(v * 255.0f);
5875 *out_a = (
nk_byte)(a * 255.0f);
5948 nk_handle handle = {0};
5966 nk_zero(&s,
sizeof(s));
5969 s.region[0] = (
unsigned short)r.x;
5970 s.region[1] = (
unsigned short)r.y;
5971 s.region[2] = (
unsigned short)r.w;
5972 s.region[3] = (
unsigned short)r.h;
5980 nk_zero(&s,
sizeof(s));
5983 s.region[0] = (
unsigned short)r.x;
5984 s.region[1] = (
unsigned short)r.y;
5985 s.region[2] = (
unsigned short)r.w;
5986 s.region[3] = (
unsigned short)r.h;
5995 nk_zero(&s,
sizeof(s));
5998 s.region[0] = (
unsigned short)r.x;
5999 s.region[1] = (
unsigned short)r.y;
6000 s.region[2] = (
unsigned short)r.w;
6001 s.region[3] = (
unsigned short)r.h;
6009 nk_zero(&s,
sizeof(s));
6023 nk_zero(&s,
sizeof(s));
6038 nk_zero(&s,
sizeof(s));
6052 return !(img->
w == 0 && img->
h == 0);
6056 nk_unify(
struct nk_rect *clip,
const struct nk_rect *a,
float x0,
float y0,
6071 float pad_x,
float pad_y,
enum nk_heading direction)
6073 float w_half, h_half;
6078 r.
w = r.
w - 2 * pad_x;
6079 r.
h = r.
h - 2 * pad_y;
6084 w_half = r.
w / 2.0f;
6085 h_half = r.
h / 2.0f;
6087 if (direction ==
NK_UP) {
6091 }
else if (direction ==
NK_RIGHT) {
6093 result[1] =
nk_vec2(r.
x + r.
w, r.
y + h_half);
6095 }
else if (direction ==
NK_DOWN) {
6098 result[2] =
nk_vec2(r.
x + w_half, r.
y + r.
h);
6107 nk_text_clamp(
const struct nk_user_font *font,
const char *text,
6108 int text_len,
float space,
int *glyphs,
float *text_width,
6109 nk_rune *sep_list,
int sep_count)
6113 float last_width = 0;
6114 nk_rune unicode = 0;
6122 float sep_width = 0;
6123 sep_count =
NK_MAX(sep_count,0);
6126 while (glyph_len && (width < space) && (len < text_len)) {
6129 for (i = 0; i < sep_count; ++i) {
6130 if (unicode != sep_list[i])
continue;
6131 sep_width = last_width = width;
6136 if (i ==
NK_MAX(sep_count,0)){
6137 last_width = sep_width = width;
6141 glyph_len =
nk_utf_decode(&text[len], &unicode, text_len - len);
6144 if (len >= text_len) {
6146 *text_width = last_width;
6150 *text_width = sep_width;
6151 return (!sep_len) ? len: sep_len;
6155 enum {NK_DO_NOT_STOP_ON_NEW_LINE, NK_STOP_ON_NEW_LINE};
6158 const char *begin,
int byte_len,
float row_height,
const char **remaining,
6159 struct nk_vec2 *out_offset,
int *glyphs,
int op)
6161 float line_height = row_height;
6163 float line_width = 0.0f;
6167 nk_rune unicode = 0;
6169 if (!begin || byte_len <= 0 || !font)
6173 if (!glyph_len)
return text_size;
6174 glyph_width = font->width(font->userdata, font->height, begin, glyph_len);
6177 while ((text_len < byte_len) && glyph_len) {
6178 if (unicode ==
'\n') {
6179 text_size.
x =
NK_MAX(text_size.
x, line_width);
6180 text_size.
y += line_height;
6183 if (op == NK_STOP_ON_NEW_LINE)
6187 glyph_len =
nk_utf_decode(begin + text_len, &unicode, byte_len-text_len);
6191 if (unicode ==
'\r') {
6194 glyph_len =
nk_utf_decode(begin + text_len, &unicode, byte_len-text_len);
6198 *glyphs = *glyphs + 1;
6199 text_len += glyph_len;
6200 line_width += (float)glyph_width;
6201 glyph_len =
nk_utf_decode(begin + text_len, &unicode, byte_len-text_len);
6202 glyph_width = font->width(font->userdata, font->height, begin+text_len, glyph_len);
6206 if (text_size.
x < line_width)
6207 text_size.
x = line_width;
6209 *out_offset =
nk_vec2(line_width, text_size.
y + line_height);
6210 if (line_width > 0 || text_size.
y == 0.0f)
6211 text_size.
y += line_height;
6213 *remaining = begin+text_len;
6228 nk_utf_validate(nk_rune *u,
int i)
6232 if (!
NK_BETWEEN(*u, nk_utfmin[i], nk_utfmax[i]) ||
6235 for (i = 1; *u > nk_utfmax[i]; ++i);
6240 nk_utf_decode_byte(
char c,
int *i)
6244 for(*i = 0; *i < (
int)
NK_LEN(nk_utfmask); ++(*i)) {
6245 if (((nk_byte)c & nk_utfmask[*i]) == nk_utfbyte[*i])
6246 return (nk_byte)(c & ~nk_utfmask[*i]);
6254 int i, j, len, type=0;
6260 if (!c || !u)
return 0;
6261 if (!clen)
return 0;
6264 udecoded = nk_utf_decode_byte(c[0], &len);
6268 for (i = 1, j = 1; i < clen && j < len; ++i, ++j) {
6269 udecoded = (udecoded << 6) | nk_utf_decode_byte(c[i], &type);
6276 nk_utf_validate(u, len);
6281 nk_utf_encode_byte(nk_rune u,
int i)
6283 return (
char)((nk_utfbyte[i]) | ((nk_byte)u & ~nk_utfmask[i]));
6290 len = nk_utf_validate(&u, 0);
6294 for (i = len - 1; i != 0; --i) {
6295 c[i] = nk_utf_encode_byte(u, 0);
6298 c[0] = nk_utf_encode_byte(u, len);
6313 if (!str || !len)
return 0;
6318 while (glyph_len && src_len < len) {
6320 src_len = src_len + glyph_len;
6321 glyph_len =
nk_utf_decode(text + src_len, &unicode, text_len - src_len);
6327 nk_utf_at(
const char *buffer,
int length,
int index,
6328 nk_rune *unicode,
int *len)
6340 if (!buffer || !unicode || !len)
return 0;
6357 src_len = src_len + glyph_len;
6358 glyph_len =
nk_utf_decode(text + src_len, unicode, text_len - src_len);
6360 if (i != index)
return 0;
6361 return buffer + src_len;
6369 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
6370 NK_INTERN void* nk_malloc(nk_handle unused,
void *old,nk_size size)
6372 NK_INTERN void nk_mfree(nk_handle unused,
void *ptr)
6376 nk_buffer_init_default(
struct nk_buffer *buffer)
6380 alloc.
alloc = nk_malloc;
6381 alloc.
free = nk_mfree;
6388 nk_size initial_size)
6392 NK_ASSERT(initial_size);
6393 if (!b || !a || !initial_size)
return;
6395 nk_zero(b,
sizeof(*b));
6399 b->
size = initial_size;
6410 if (!b || !m || !size)
return;
6412 nk_zero(b,
sizeof(*b));
6420 nk_buffer_align(
void *unaligned, nk_size align, nk_size *alignment,
6430 *alignment = (
nk_size)((nk_byte*)memory - (nk_byte*)unaligned);
6439 *alignment = (
nk_size)((nk_byte*)unaligned - (nk_byte*)memory);
6450 nk_buffer_realloc(
struct nk_buffer *b, nk_size capacity, nk_size *size)
6463 if (!temp)
return 0;
6467 NK_MEMCPY(temp, b->
memory.
ptr, buffer_size);
6471 if (b->
size == buffer_size) {
6479 back_size = buffer_size - b->
size;
6480 dst =
nk_ptr_add(
void, temp, capacity - back_size);
6482 NK_MEMCPY(dst, src, back_size);
6483 b->
size = capacity - back_size;
6490 nk_size size, nk_size align)
6499 if (!b || !size)
return 0;
6506 memory = nk_buffer_align(unaligned, align, &alignment, type);
6523 capacity =
NK_MAX(capacity, nk_round_up_pow2((nk_uint)(b->
allocated + size)));
6531 memory = nk_buffer_align(unaligned, align, &alignment, type);
6536 else b->
size -= (size + alignment);
6544 const void *memory, nk_size size, nk_size align)
6546 void *mem = nk_buffer_alloc(b, type, size, align);
6548 NK_MEMCPY(mem, memory, size);
6555 if (!buffer)
return;
6566 if (!buffer)
return;
6611 if (!s || !b)
return;
6623 if (!buffer)
return 0;
6631 if (!buffer)
return 0;
6639 if (!buffer)
return 0;
6650 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
6652 nk_str_init_default(
struct nk_str *str)
6656 alloc.
alloc = nk_malloc;
6657 alloc.
free = nk_mfree;
6683 if (!s || !str || !len)
return 0;
6686 NK_MEMCPY(mem, str, (nk_size)len *
sizeof(
char));
6703 if (!str || !text || !len)
return 0;
6704 for (i = 0; i < len; ++i)
6718 if (!str || !text)
return 0;
6720 glyph_len = byte_len =
nk_utf_decode(text+byte_len, &unicode, 4);
6721 while (unicode !=
'\0' && glyph_len) {
6723 byte_len += glyph_len;
6738 if (!str || !text || !len)
return 0;
6739 for (i = 0; i < len; ++i) {
6741 if (!byte_len)
break;
6754 if (!str || !runes)
return 0;
6755 while (runes[i] !=
'\0') {
6774 NK_ASSERT(len >= 0);
6775 if (!s || !str || !len || (nk_size)pos > s->
buffer.
allocated)
return 0;
6788 NK_ASSERT(((
int)pos + (
int)len + ((
int)copylen - 1)) >= 0);
6789 NK_ASSERT(((
int)pos + ((
int)copylen - 1)) >= 0);
6792 for (i = 0; i < copylen; ++i) *dst-- = *src--;
6794 NK_MEMCPY(mem, str, (nk_size)len *
sizeof(
char));
6810 if (!str || !cstr || !len)
return 0;
6815 if (!begin)
return 0;
6840 if (!str || !text || !len)
return 0;
6841 for (i = 0; i < len; ++i)
6855 if (!str || !text)
return 0;
6857 glyph_len = byte_len =
nk_utf_decode(text+byte_len, &unicode, 4);
6858 while (unicode !=
'\0' && glyph_len) {
6860 byte_len += glyph_len;
6875 if (!str || !runes || !len)
return 0;
6876 for (i = 0; i < len; ++i) {
6878 if (!byte_len)
break;
6891 if (!str || !runes)
return 0;
6892 while (runes[i] !=
'\0') {
6904 NK_ASSERT(len >= 0);
6920 NK_ASSERT(len >= 0);
6921 if (!str || len < 0)
return;
6922 if (len >= str->
len) {
6927 index = str->
len - len;
6961 NK_ASSERT(s->
len >= pos + len);
6962 if (s->
len < pos + len)
6997 if (!str || !unicode || !len)
return 0;
7014 src_len = src_len + glyph_len;
7015 glyph_len =
nk_utf_decode(text + src_len, unicode, text_len - src_len);
7017 if (i != pos)
return 0;
7018 return text + src_len;
7042 if (!str || !unicode || !len)
return 0;
7059 src_len = src_len + glyph_len;
7060 glyph_len =
nk_utf_decode(text + src_len, unicode, text_len - src_len);
7062 if (i != pos)
return 0;
7063 return text + src_len;
7070 nk_rune unicode = 0;
7136 if (!cmdbuf || !buffer)
return;
7137 cmdbuf->
base = buffer;
7148 if (!buffer)
return;
7152 buffer->
clip = nk_null_rect;
7153 #ifdef NK_INCLUDE_COMMAND_USERDATA
7176 unaligned = (nk_byte*)cmd + size;
7178 alignment = (
nk_size)((nk_byte*)memory - (nk_byte*)unaligned);
7179 #ifdef NK_ZERO_COMMAND_MEMORY
7180 NK_MEMSET(cmd, 0, size + alignment);
7185 #ifdef NK_INCLUDE_COMMAND_USERDATA
7207 cmd->
x = (short)r.
x;
7208 cmd->
y = (
short)r.
y;
7209 cmd->
w = (
unsigned short)
NK_MAX(0, r.
w);
7210 cmd->
h = (
unsigned short)
NK_MAX(0, r.
h);
7215 float x1,
float y1,
float line_thickness,
struct nk_color c)
7224 cmd->
begin.
x = (short)x0;
7225 cmd->
begin.
y = (short)y0;
7226 cmd->
end.
x = (short)x1;
7227 cmd->
end.
y = (short)y1;
7233 float ctrl0x,
float ctrl0y,
float ctrl1x,
float ctrl1y,
7234 float bx,
float by,
float line_thickness,
struct nk_color col)
7238 if (!b || col.
a == 0)
return;
7244 cmd->
begin.
x = (short)ax;
7245 cmd->
begin.
y = (short)ay;
7246 cmd->
ctrl[0].
x = (short)ctrl0x;
7247 cmd->
ctrl[0].
y = (short)ctrl0y;
7248 cmd->
ctrl[1].
x = (short)ctrl1x;
7249 cmd->
ctrl[1].
y = (short)ctrl1y;
7250 cmd->
end.
x = (short)bx;
7251 cmd->
end.
y = (short)by;
7257 float rounding,
float line_thickness,
struct nk_color c)
7261 if (!b || c.
a == 0 || rect.
w == 0 || rect.
h == 0)
return;
7265 clip->
x, clip->
y, clip->
w, clip->
h))
return;
7271 cmd->
rounding = (
unsigned short)rounding;
7273 cmd->
x = (short)rect.
x;
7274 cmd->
y = (
short)rect.
y;
7275 cmd->
w = (
unsigned short)
NK_MAX(0, rect.
w);
7276 cmd->
h = (
unsigned short)
NK_MAX(0, rect.
h);
7286 if (!b || c.
a == 0 || rect.
w == 0 || rect.
h == 0)
return;
7290 clip->
x, clip->
y, clip->
w, clip->
h))
return;
7296 cmd->
rounding = (
unsigned short)rounding;
7297 cmd->
x = (short)rect.
x;
7298 cmd->
y = (
short)rect.
y;
7299 cmd->
w = (
unsigned short)
NK_MAX(0, rect.
w);
7300 cmd->
h = (
unsigned short)
NK_MAX(0, rect.
h);
7311 if (!b || rect.
w == 0 || rect.
h == 0)
return;
7315 clip->
x, clip->
y, clip->
w, clip->
h))
return;
7321 cmd->
x = (short)rect.
x;
7322 cmd->
y = (
short)rect.
y;
7323 cmd->
w = (
unsigned short)
NK_MAX(0, rect.
w);
7324 cmd->
h = (
unsigned short)
NK_MAX(0, rect.
h);
7333 float line_thickness,
struct nk_color c)
7336 if (!b || r.
w == 0 || r.
h == 0)
return;
7347 cmd->
x = (short)r.
x;
7348 cmd->
y = (
short)r.
y;
7349 cmd->
w = (
unsigned short)
NK_MAX(r.
w, 0);
7350 cmd->
h = (
unsigned short)
NK_MAX(r.
h, 0);
7359 if (!b || c.
a == 0 || r.
w == 0 || r.
h == 0)
return;
7369 cmd->
x = (short)r.
x;
7370 cmd->
y = (
short)r.
y;
7371 cmd->
w = (
unsigned short)
NK_MAX(r.
w, 0);
7372 cmd->
h = (
unsigned short)
NK_MAX(r.
h, 0);
7378 float a_min,
float a_max,
float line_thickness,
struct nk_color c)
7381 if (!b || c.
a == 0)
return;
7386 cmd->
cx = (short)cx;
7387 cmd->
cy = (short)cy;
7388 cmd->
r = (
unsigned short)radius;
7396 float a_min,
float a_max,
struct nk_color c)
7400 if (!b || c.
a == 0)
return;
7404 cmd->
cx = (short)cx;
7405 cmd->
cy = (short)cy;
7406 cmd->
r = (
unsigned short)radius;
7414 float y1,
float x2,
float y2,
float line_thickness,
struct nk_color c)
7418 if (!b || c.
a == 0)
return;
7421 if (!
NK_INBOX(x0, y0, clip->
x, clip->
y, clip->
w, clip->
h) &&
7422 !
NK_INBOX(x1, y1, clip->
x, clip->
y, clip->
w, clip->
h) &&
7431 cmd->
a.
x = (short)x0;
7432 cmd->
a.
y = (short)y0;
7433 cmd->
b.
x = (short)x1;
7434 cmd->
b.
y = (short)y1;
7435 cmd->
c.
x = (short)x2;
7436 cmd->
c.
y = (short)y2;
7442 float y1,
float x2,
float y2,
struct nk_color c)
7446 if (!b || c.
a == 0)
return;
7450 if (!
NK_INBOX(x0, y0, clip->
x, clip->
y, clip->
w, clip->
h) &&
7451 !
NK_INBOX(x1, y1, clip->
x, clip->
y, clip->
w, clip->
h) &&
7459 cmd->
a.
x = (short)x0;
7460 cmd->
a.
y = (short)y0;
7461 cmd->
b.
x = (short)x1;
7462 cmd->
b.
y = (short)y1;
7463 cmd->
c.
x = (short)x2;
7464 cmd->
c.
y = (short)y2;
7470 float line_thickness,
struct nk_color col)
7477 if (!b || col.
a == 0)
return;
7478 size =
sizeof(*cmd) +
sizeof(short) * 2 * (nk_size)point_count;
7482 cmd->line_thickness = (
unsigned short)line_thickness;
7483 cmd->point_count = (
unsigned short)point_count;
7484 for (i = 0; i < point_count; ++i) {
7485 cmd->
points[i].
x = (short)points[i*2];
7486 cmd->
points[i].
y = (short)points[i*2+1];
7499 if (!b || col.
a == 0)
return;
7500 size =
sizeof(*cmd) +
sizeof(short) * 2 * (nk_size)point_count;
7505 cmd->point_count = (
unsigned short)point_count;
7506 for (i = 0; i < point_count; ++i) {
7507 cmd->
points[i].
x = (short)points[i*2+0];
7508 cmd->
points[i].
y = (short)points[i*2+1];
7514 float line_thickness,
struct nk_color col)
7521 if (!b || col.
a == 0)
return;
7522 size =
sizeof(*cmd) +
sizeof(short) * 2 * (nk_size)point_count;
7526 cmd->point_count = (
unsigned short)point_count;
7527 cmd->line_thickness = (
unsigned short)line_thickness;
7528 for (i = 0; i < point_count; ++i) {
7529 cmd->
points[i].
x = (short)points[i*2];
7530 cmd->
points[i].
y = (short)points[i*2+1];
7550 cmd->
x = (short)r.
x;
7551 cmd->
y = (
short)r.
y;
7552 cmd->
w = (
unsigned short)
NK_MAX(0, r.
w);
7553 cmd->
h = (
unsigned short)
NK_MAX(0, r.
h);
7574 cmd->
x = (short)r.
x;
7575 cmd->
y = (
short)r.
y;
7576 cmd->
w = (
unsigned short)
NK_MAX(0, r.
w);
7577 cmd->
h = (
unsigned short)
NK_MAX(0, r.
h);
7584 const char *
string,
int length,
const struct nk_user_font *font,
7587 float text_width = 0;
7592 if (!b || !
string || !length || (bg.
a == 0 && fg.
a == 0))
return;
7601 if (text_width > r.
w){
7603 float txt_width = (float)text_width;
7604 length = nk_text_clamp(font,
string, length, r.
w, &glyphs, &txt_width, 0,0);
7607 if (!length)
return;
7611 cmd->
x = (short)r.
x;
7612 cmd->
y = (
short)r.
y;
7613 cmd->
w = (
unsigned short)r.
w;
7614 cmd->
h = (
unsigned short)r.
h;
7620 NK_MEMCPY(cmd->
string,
string, (nk_size)length);
7629 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
7631 nk_draw_list_init(
struct nk_draw_list *list)
7636 nk_zero(list,
sizeof(*list));
7637 for (i = 0; i <
NK_LEN(list->circle_vtx); ++i) {
7638 const float a = ((float)i / (
float)
NK_LEN(list->circle_vtx)) * 2 *
NK_PI;
7639 list->circle_vtx[i].x = (float)NK_COS(a);
7640 list->circle_vtx[i].y = (float)NK_SIN(a);
7651 NK_ASSERT(vertices);
7652 NK_ASSERT(elements);
7653 if (!canvas || !config || !cmds || !vertices || !elements)
7656 canvas->buffer = cmds;
7657 canvas->config = *
config;
7658 canvas->elements = elements;
7659 canvas->vertices = vertices;
7660 canvas->clip_rect = nk_null_rect;
7663 NK_API const struct nk_draw_command*
7664 nk__draw_list_begin(
const struct nk_draw_list *canvas,
const struct nk_buffer *buffer)
7668 const struct nk_draw_command *cmd;
7671 if (!buffer || !buffer->
size || !canvas->cmd_count)
7675 offset = buffer->
memory.
size - canvas->cmd_offset;
7676 cmd =
nk_ptr_add(
const struct nk_draw_command, memory, offset);
7680 NK_API const struct nk_draw_command*
7681 nk__draw_list_end(
const struct nk_draw_list *canvas,
const struct nk_buffer *buffer)
7686 const struct nk_draw_command *end;
7690 if (!buffer || !canvas)
7695 offset = size - canvas->cmd_offset;
7696 end =
nk_ptr_add(
const struct nk_draw_command, memory, offset);
7697 end -= (canvas->cmd_count-1);
7701 NK_API const struct nk_draw_command*
7702 nk__draw_list_next(
const struct nk_draw_command *cmd,
7703 const struct nk_buffer *buffer,
const struct nk_draw_list *canvas)
7705 const struct nk_draw_command *end;
7708 if (!cmd || !buffer || !canvas)
7711 end = nk__draw_list_end(canvas, buffer);
7712 if (cmd <= end)
return 0;
7717 nk_draw_list_clear(
struct nk_draw_list *list)
7728 list->element_count = 0;
7729 list->vertex_count = 0;
7730 list->cmd_offset = 0;
7731 list->cmd_count = 0;
7732 list->path_count = 0;
7735 list->clip_rect = nk_null_rect;
7739 nk_draw_list_alloc_path(
struct nk_draw_list *list,
int count)
7746 point_size * (nk_size)count, point_align);
7748 if (!points)
return 0;
7749 if (!list->path_offset) {
7751 list->path_offset = (
unsigned int)((nk_byte*)points - (nk_byte*)memory);
7753 list->path_count += (
unsigned int)count;
7758 nk_draw_list_path_last(struct nk_draw_list *list)
7762 NK_ASSERT(list->path_count);
7765 point += (list->path_count-1);
7770 nk_draw_list_push_command(
struct nk_draw_list *list,
struct nk_rect clip,
7774 NK_STORAGE const nk_size cmd_size =
sizeof(
struct nk_draw_command);
7775 struct nk_draw_command *cmd;
7778 cmd = (
struct nk_draw_command*)
7779 nk_buffer_alloc(list->buffer,
NK_BUFFER_BACK, cmd_size, cmd_align);
7782 if (!list->cmd_count) {
7786 list->cmd_offset = (
nk_size)(memory - (nk_byte*)cmd);
7789 cmd->elem_count = 0;
7790 cmd->clip_rect = clip;
7792 #ifdef NK_INCLUDE_COMMAND_USERDATA
7793 cmd->userdata = list->userdata;
7797 list->clip_rect = clip;
7802 nk_draw_list_command_last(
struct nk_draw_list *list)
7806 struct nk_draw_command *cmd;
7807 NK_ASSERT(list->cmd_count);
7811 cmd =
nk_ptr_add(
struct nk_draw_command, memory, size - list->cmd_offset);
7812 return (cmd - (list->cmd_count-1));
7816 nk_draw_list_add_clip(
struct nk_draw_list *list,
struct nk_rect rect)
7820 if (!list->cmd_count) {
7821 nk_draw_list_push_command(list, rect, list->config.null.texture);
7823 struct nk_draw_command *prev = nk_draw_list_command_last(list);
7824 if (prev->elem_count == 0)
7825 prev->clip_rect = rect;
7826 nk_draw_list_push_command(list, rect, prev->texture);
7831 nk_draw_list_push_image(
struct nk_draw_list *list, nk_handle texture)
7835 if (!list->cmd_count) {
7836 nk_draw_list_push_command(list, nk_null_rect, texture);
7838 struct nk_draw_command *prev = nk_draw_list_command_last(list);
7839 if (prev->elem_count == 0)
7841 else if (prev->texture.id != texture.
id)
7842 nk_draw_list_push_command(list, prev->clip_rect, texture);
7846 #ifdef NK_INCLUDE_COMMAND_USERDATA
7848 nk_draw_list_push_userdata(
struct nk_draw_list *list, nk_handle userdata)
7850 list->userdata = userdata;
7855 nk_draw_list_alloc_vertices(
struct nk_draw_list *list, nk_size count)
7859 if (!list)
return 0;
7861 list->config.vertex_size*count, list->config.vertex_alignment);
7863 list->vertex_count += (
unsigned int)count;
7868 nk_draw_list_alloc_elements(
struct nk_draw_list *list, nk_size count)
7871 struct nk_draw_command *cmd;
7873 NK_STORAGE const nk_size elem_size =
sizeof(nk_draw_index);
7875 if (!list)
return 0;
7877 ids = (nk_draw_index*)
7878 nk_buffer_alloc(list->elements,
NK_BUFFER_FRONT, elem_size*count, elem_align);
7880 cmd = nk_draw_list_command_last(list);
7881 list->element_count += (
unsigned int)count;
7882 cmd->elem_count += (
unsigned int)count;
7887 nk_draw_vertex_layout_element_is_end_of_layout(
7888 const struct nk_draw_vertex_layout_element *element)
7890 return (element->attribute == NK_VERTEX_ATTRIBUTE_COUNT ||
7891 element->format == NK_FORMAT_COUNT);
7895 nk_draw_vertex_color(
void *attribute,
const float *values,
7896 enum nk_draw_vertex_layout_format format)
7899 NK_ASSERT(format >= NK_FORMAT_COLOR_BEGIN);
7900 NK_ASSERT(format <= NK_FORMAT_COLOR_END);
7901 if (format < NK_FORMAT_COLOR_BEGIN || format > NK_FORMAT_COLOR_END)
return;
7904 default: NK_ASSERT(0 &&
"Invalid vertex layout color format");
break;
7905 case NK_FORMAT_R8G8B8A8:
7906 case NK_FORMAT_R8G8B8: {
7908 NK_MEMCPY(attribute, &col.
r,
sizeof(col));
7910 case NK_FORMAT_R16G15B16: {
7912 col[0] = (
nk_ushort)
NK_CLAMP(NK_USHORT_MIN, values[0] * NK_USHORT_MAX, NK_USHORT_MAX);
7913 col[1] = (
nk_ushort)
NK_CLAMP(NK_USHORT_MIN, values[1] * NK_USHORT_MAX, NK_USHORT_MAX);
7914 col[2] = (
nk_ushort)
NK_CLAMP(NK_USHORT_MIN, values[2] * NK_USHORT_MAX, NK_USHORT_MAX);
7915 NK_MEMCPY(attribute, col,
sizeof(col));
7917 case NK_FORMAT_R16G15B16A16: {
7919 col[0] = (
nk_ushort)
NK_CLAMP(NK_USHORT_MIN, values[0] * NK_USHORT_MAX, NK_USHORT_MAX);
7920 col[1] = (
nk_ushort)
NK_CLAMP(NK_USHORT_MIN, values[1] * NK_USHORT_MAX, NK_USHORT_MAX);
7921 col[2] = (
nk_ushort)
NK_CLAMP(NK_USHORT_MIN, values[2] * NK_USHORT_MAX, NK_USHORT_MAX);
7922 col[3] = (
nk_ushort)
NK_CLAMP(NK_USHORT_MIN, values[3] * NK_USHORT_MAX, NK_USHORT_MAX);
7923 NK_MEMCPY(attribute, col,
sizeof(col));
7925 case NK_FORMAT_R32G32B32: {
7927 col[0] = (
nk_uint)
NK_CLAMP(NK_UINT_MIN, values[0] * NK_UINT_MAX, NK_UINT_MAX);
7928 col[1] = (
nk_uint)
NK_CLAMP(NK_UINT_MIN, values[1] * NK_UINT_MAX, NK_UINT_MAX);
7929 col[2] = (
nk_uint)
NK_CLAMP(NK_UINT_MIN, values[2] * NK_UINT_MAX, NK_UINT_MAX);
7930 NK_MEMCPY(attribute, col,
sizeof(col));
7932 case NK_FORMAT_R32G32B32A32: {
7934 col[0] = (
nk_uint)
NK_CLAMP(NK_UINT_MIN, values[0] * NK_UINT_MAX, NK_UINT_MAX);
7935 col[1] = (
nk_uint)
NK_CLAMP(NK_UINT_MIN, values[1] * NK_UINT_MAX, NK_UINT_MAX);
7936 col[2] = (
nk_uint)
NK_CLAMP(NK_UINT_MIN, values[2] * NK_UINT_MAX, NK_UINT_MAX);
7937 col[3] = (
nk_uint)
NK_CLAMP(NK_UINT_MIN, values[3] * NK_UINT_MAX, NK_UINT_MAX);
7938 NK_MEMCPY(attribute, col,
sizeof(col));
7940 case NK_FORMAT_R32G32B32A32_FLOAT:
7941 NK_MEMCPY(attribute, values,
sizeof(
float)*4);
7943 case NK_FORMAT_R32G32B32A32_DOUBLE: {
7949 NK_MEMCPY(attribute, col,
sizeof(col));
7951 case NK_FORMAT_RGB32:
7952 case NK_FORMAT_RGBA32: {
7955 NK_MEMCPY(attribute, &color,
sizeof(color));
7961 nk_draw_vertex_element(
void *dst,
const float *values,
int value_count,
7962 enum nk_draw_vertex_layout_format format)
7965 void *attribute = dst;
7967 NK_ASSERT(format < NK_FORMAT_COLOR_BEGIN);
7968 if (format >= NK_FORMAT_COLOR_BEGIN && format <= NK_FORMAT_COLOR_END)
return;
7969 for (value_index = 0; value_index < value_count; ++value_index) {
7971 default: NK_ASSERT(0 &&
"invalid vertex layout format");
break;
7972 case NK_FORMAT_SCHAR: {
7973 char value = (char)
NK_CLAMP(NK_SCHAR_MIN, values[value_index], NK_SCHAR_MAX);
7974 NK_MEMCPY(attribute, &value,
sizeof(value));
7975 attribute = (
void*)((
char*)attribute +
sizeof(char));
7977 case NK_FORMAT_SSHORT: {
7978 nk_short value = (
nk_short)
NK_CLAMP(NK_SSHORT_MIN, values[value_index], NK_SSHORT_MAX);
7979 NK_MEMCPY(attribute, &value,
sizeof(value));
7980 attribute = (
void*)((
char*)attribute +
sizeof(
value));
7982 case NK_FORMAT_SINT: {
7983 nk_int value = (
nk_int)
NK_CLAMP(NK_SINT_MIN, values[value_index], NK_SINT_MAX);
7984 NK_MEMCPY(attribute, &value,
sizeof(value));
7985 attribute = (
void*)((
char*)attribute +
sizeof(
nk_int));
7987 case NK_FORMAT_UCHAR: {
7988 unsigned char value = (
unsigned char)
NK_CLAMP(NK_UCHAR_MIN, values[value_index], NK_UCHAR_MAX);
7989 NK_MEMCPY(attribute, &value,
sizeof(value));
7990 attribute = (
void*)((
char*)attribute +
sizeof(
unsigned char));
7992 case NK_FORMAT_USHORT: {
7993 nk_ushort value = (
nk_ushort)
NK_CLAMP(NK_USHORT_MIN, values[value_index], NK_USHORT_MAX);
7994 NK_MEMCPY(attribute, &value,
sizeof(value));
7995 attribute = (
void*)((
char*)attribute +
sizeof(
value));
7997 case NK_FORMAT_UINT: {
7998 nk_uint value = (
nk_uint)
NK_CLAMP(NK_UINT_MIN, values[value_index], NK_UINT_MAX);
7999 NK_MEMCPY(attribute, &value,
sizeof(value));
8000 attribute = (
void*)((
char*)attribute +
sizeof(
nk_uint));
8002 case NK_FORMAT_FLOAT:
8003 NK_MEMCPY(attribute, &values[value_index],
sizeof(values[value_index]));
8004 attribute = (
void*)((
char*)attribute +
sizeof(float));
8006 case NK_FORMAT_DOUBLE: {
8007 double value = (double)values[value_index];
8008 NK_MEMCPY(attribute, &value,
sizeof(value));
8009 attribute = (
void*)((
char*)attribute +
sizeof(double));
8019 void *result = (
void*)((
char*)dst + config->
vertex_size);
8020 const struct nk_draw_vertex_layout_element *elem_iter = config->
vertex_layout;
8021 while (!nk_draw_vertex_layout_element_is_end_of_layout(elem_iter)) {
8022 void *address = (
void*)((
char*)dst + elem_iter->offset);
8023 switch (elem_iter->attribute) {
8024 case NK_VERTEX_ATTRIBUTE_COUNT:
8025 default: NK_ASSERT(0 &&
"wrong element attribute");
8026 case NK_VERTEX_POSITION: nk_draw_vertex_element(address, &pos.
x, 2, elem_iter->format);
break;
8027 case NK_VERTEX_TEXCOORD: nk_draw_vertex_element(address, &uv.
x, 2, elem_iter->format);
break;
8028 case NK_VERTEX_COLOR: nk_draw_vertex_color(address, &color.
r, elem_iter->format);
break;
8036 nk_draw_list_stroke_poly_line(
struct nk_draw_list *list,
const struct nk_vec2 *points,
8037 const unsigned int points_count,
struct nk_color color,
enum nk_draw_list_stroke closed,
8045 if (!list || points_count < 2)
return;
8047 color.
a = (
nk_byte)((
float)color.
a * list->config.global_alpha);
8048 count = points_count;
8049 if (!closed) count = points_count-1;
8050 thick_line = thickness > 1.0f;
8052 #ifdef NK_INCLUDE_COMMAND_USERDATA
8053 nk_draw_list_push_userdata(list, list->userdata);
8056 color.
a = (
nk_byte)((
float)color.
a * list->config.global_alpha);
8063 const float AA_SIZE = 1.0f;
8069 nk_size vertex_offset;
8070 nk_size index = list->vertex_count;
8072 const nk_size idx_count = (thick_line) ? (count * 18) : (count * 12);
8073 const nk_size vtx_count = (thick_line) ? (points_count * 4): (points_count *3);
8075 void *vtx = nk_draw_list_alloc_vertices(list, vtx_count);
8076 nk_draw_index *ids = nk_draw_list_alloc_elements(list, idx_count);
8079 struct nk_vec2 *normals, *temp;
8080 if (!vtx || !ids)
return;
8083 vertex_offset = (
nk_size)((nk_byte*)vtx - (nk_byte*)list->vertices->memory.ptr);
8085 size = pnt_size * ((thick_line) ? 5 : 3) * points_count;
8088 if (!normals)
return;
8089 temp = normals + points_count;
8092 vtx = (
void*)((nk_byte*)list->vertices->memory.ptr + vertex_offset);
8095 for (i1 = 0; i1 < count; ++i1) {
8096 const nk_size i2 = ((i1 + 1) == points_count) ? 0 : (i1 + 1);
8103 len = nk_inv_sqrt(len);
8107 normals[i1].
x = diff.
y;
8108 normals[i1].
y = -diff.
x;
8112 normals[points_count-1] = normals[points_count-2];
8121 temp[(points_count-1) * 2 + 0] =
nk_vec2_add(points[points_count-1], d);
8122 temp[(points_count-1) * 2 + 1] =
nk_vec2_sub(points[points_count-1], d);
8127 for (i1 = 0; i1 < count; i1++) {
8130 nk_size i2 = ((i1 + 1) == points_count) ? 0 : (i1 + 1);
8131 nk_size idx2 = ((i1+1) == points_count) ? index: (idx1 + 3);
8135 dmr2 = dm.x * dm.x + dm.y* dm.y;
8136 if (dmr2 > 0.000001f) {
8137 float scale = 1.0f/dmr2;
8138 scale =
NK_MIN(100.0f, scale);
8146 ids[0] = (nk_draw_index)(idx2 + 0); ids[1] = (nk_draw_index)(idx1+0);
8147 ids[2] = (nk_draw_index)(idx1 + 2); ids[3] = (nk_draw_index)(idx1+2);
8148 ids[4] = (nk_draw_index)(idx2 + 2); ids[5] = (nk_draw_index)(idx2+0);
8149 ids[6] = (nk_draw_index)(idx2 + 1); ids[7] = (nk_draw_index)(idx1+1);
8150 ids[8] = (nk_draw_index)(idx1 + 0); ids[9] = (nk_draw_index)(idx1+0);
8151 ids[10]= (nk_draw_index)(idx2 + 0); ids[11]= (nk_draw_index)(idx2+1);
8157 for (i = 0; i < points_count; ++i) {
8158 const struct nk_vec2 uv = list->config.null.uv;
8159 vtx = nk_draw_vertex(vtx, &list->config, points[i], uv, col);
8160 vtx = nk_draw_vertex(vtx, &list->config, temp[i*2+0], uv, col_trans);
8161 vtx = nk_draw_vertex(vtx, &list->config, temp[i*2+1], uv, col_trans);
8165 const float half_inner_thickness = (thickness - AA_SIZE) * 0.5f;
8175 d1 =
nk_vec2_muls(normals[points_count-1], half_inner_thickness + AA_SIZE);
8176 d2 =
nk_vec2_muls(normals[points_count-1], half_inner_thickness);
8178 temp[(points_count-1)*4+0] =
nk_vec2_add(points[points_count-1], d1);
8179 temp[(points_count-1)*4+1] =
nk_vec2_add(points[points_count-1], d2);
8180 temp[(points_count-1)*4+2] =
nk_vec2_sub(points[points_count-1], d2);
8181 temp[(points_count-1)*4+3] =
nk_vec2_sub(points[points_count-1], d1);
8186 for (i1 = 0; i1 < count; ++i1) {
8188 const nk_size i2 = ((i1+1) == points_count) ? 0: (i1 + 1);
8189 nk_size idx2 = ((i1+1) == points_count) ? index: (idx1 + 4);
8193 float dmr2 = dm.
x * dm.
x + dm.
y* dm.
y;
8194 if (dmr2 > 0.000001f) {
8195 float scale = 1.0f/dmr2;
8196 scale =
NK_MIN(100.0f, scale);
8200 dm_out =
nk_vec2_muls(dm, ((half_inner_thickness) + AA_SIZE));
8208 ids[0] = (nk_draw_index)(idx2 + 1); ids[1] = (nk_draw_index)(idx1+1);
8209 ids[2] = (nk_draw_index)(idx1 + 2); ids[3] = (nk_draw_index)(idx1+2);
8210 ids[4] = (nk_draw_index)(idx2 + 2); ids[5] = (nk_draw_index)(idx2+1);
8211 ids[6] = (nk_draw_index)(idx2 + 1); ids[7] = (nk_draw_index)(idx1+1);
8212 ids[8] = (nk_draw_index)(idx1 + 0); ids[9] = (nk_draw_index)(idx1+0);
8213 ids[10]= (nk_draw_index)(idx2 + 0); ids[11] = (nk_draw_index)(idx2+1);
8214 ids[12]= (nk_draw_index)(idx2 + 2); ids[13] = (nk_draw_index)(idx1+2);
8215 ids[14]= (nk_draw_index)(idx1 + 3); ids[15] = (nk_draw_index)(idx1+3);
8216 ids[16]= (nk_draw_index)(idx2 + 3); ids[17] = (nk_draw_index)(idx2+2);
8222 for (i = 0; i < points_count; ++i) {
8223 const struct nk_vec2 uv = list->config.null.uv;
8224 vtx = nk_draw_vertex(vtx, &list->config, temp[i*4+0], uv, col_trans);
8225 vtx = nk_draw_vertex(vtx, &list->config, temp[i*4+1], uv, col);
8226 vtx = nk_draw_vertex(vtx, &list->config, temp[i*4+2], uv, col);
8227 vtx = nk_draw_vertex(vtx, &list->config, temp[i*4+3], uv, col_trans);
8235 nk_size idx = list->vertex_count;
8236 const nk_size idx_count = count * 6;
8237 const nk_size vtx_count = count * 4;
8238 void *vtx = nk_draw_list_alloc_vertices(list, vtx_count);
8239 nk_draw_index *ids = nk_draw_list_alloc_elements(list, idx_count);
8240 if (!vtx || !ids)
return;
8242 for (i1 = 0; i1 < count; ++i1) {
8244 const struct nk_vec2 uv = list->config.null.uv;
8245 const nk_size i2 = ((i1+1) == points_count) ? 0 : i1 + 1;
8246 const struct nk_vec2 p1 = points[i1];
8247 const struct nk_vec2 p2 = points[i2];
8254 len = nk_inv_sqrt(len);
8259 dx = diff.
x * (thickness * 0.5f);
8260 dy = diff.
y * (thickness * 0.5f);
8262 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(p1.
x + dy, p1.
y - dx), uv, col);
8263 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(p2.
x + dy, p2.
y - dx), uv, col);
8264 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(p2.
x - dy, p2.
y + dx), uv, col);
8265 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(p1.
x - dy, p1.
y + dx), uv, col);
8267 ids[0] = (nk_draw_index)(idx+0); ids[1] = (nk_draw_index)(idx+1);
8268 ids[2] = (nk_draw_index)(idx+2); ids[3] = (nk_draw_index)(idx+0);
8269 ids[4] = (nk_draw_index)(idx+2); ids[5] = (nk_draw_index)(idx+3);
8278 nk_draw_list_fill_poly_convex(
struct nk_draw_list *list,
8279 const struct nk_vec2 *points,
const unsigned int points_count,
8288 if (!list || points_count < 3)
return;
8290 #ifdef NK_INCLUDE_COMMAND_USERDATA
8291 nk_draw_list_push_userdata(list, list->userdata);
8294 color.
a = (
nk_byte)((
float)color.
a * list->config.global_alpha);
8304 const float AA_SIZE = 1.0f;
8305 nk_size vertex_offset = 0;
8306 nk_size index = list->vertex_count;
8308 const nk_size idx_count = (points_count-2)*3 + points_count*6;
8309 const nk_size vtx_count = (points_count*2);
8311 void *vtx = nk_draw_list_alloc_vertices(list, vtx_count);
8312 nk_draw_index *ids = nk_draw_list_alloc_elements(list, idx_count);
8316 unsigned int vtx_inner_idx = (
unsigned int)(index + 0);
8317 unsigned int vtx_outer_idx = (
unsigned int)(index + 1);
8318 if (!vtx || !ids)
return;
8321 vertex_offset = (
nk_size)((nk_byte*)vtx - (nk_byte*)list->vertices->memory.ptr);
8323 size = pnt_size * points_count;
8326 if (!normals)
return;
8327 vtx = (
void*)((nk_byte*)list->vertices->memory.ptr + vertex_offset);
8330 for (i = 2; i < points_count; i++) {
8331 ids[0] = (nk_draw_index)(vtx_inner_idx);
8332 ids[1] = (nk_draw_index)(vtx_inner_idx + ((i-1) << 1));
8333 ids[2] = (nk_draw_index)(vtx_inner_idx + (i << 1));
8338 for (i0 = points_count-1, i1 = 0; i1 < points_count; i0 = i1++) {
8339 struct nk_vec2 p0 = points[i0];
8340 struct nk_vec2 p1 = points[i1];
8346 len = nk_inv_sqrt(len);
8350 normals[i0].
x = diff.
y;
8351 normals[i0].
y = -diff.
x;
8355 for (i0 = points_count-1, i1 = 0; i1 < points_count; i0 = i1++) {
8356 const struct nk_vec2 uv = list->config.null.uv;
8357 struct nk_vec2 n0 = normals[i0];
8358 struct nk_vec2 n1 = normals[i1];
8360 float dmr2 = dm.
x*dm.
x + dm.
y*dm.
y;
8361 if (dmr2 > 0.000001f) {
8362 float scale = 1.0f / dmr2;
8363 scale =
NK_MIN(scale, 100.0f);
8369 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2_sub(points[i1], dm), uv, col);
8370 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2_add(points[i1], dm), uv, col_trans);
8373 ids[0] = (nk_draw_index)(vtx_inner_idx+(i1<<1));
8374 ids[1] = (nk_draw_index)(vtx_inner_idx+(i0<<1));
8375 ids[2] = (nk_draw_index)(vtx_outer_idx+(i0<<1));
8376 ids[3] = (nk_draw_index)(vtx_outer_idx+(i0<<1));
8377 ids[4] = (nk_draw_index)(vtx_outer_idx+(i1<<1));
8378 ids[5] = (nk_draw_index)(vtx_inner_idx+(i1<<1));
8385 nk_size index = list->vertex_count;
8386 const nk_size idx_count = (points_count-2)*3;
8387 const nk_size vtx_count = points_count;
8388 void *vtx = nk_draw_list_alloc_vertices(list, vtx_count);
8389 nk_draw_index *ids = nk_draw_list_alloc_elements(list, idx_count);
8391 if (!vtx || !ids)
return;
8392 for (i = 0; i < vtx_count; ++i)
8393 vtx = nk_draw_vertex(vtx, &list->config, points[i], list->config.null.uv, col);
8394 for (i = 2; i < points_count; ++i) {
8395 ids[0] = (nk_draw_index)index;
8396 ids[1] = (nk_draw_index)(index+ i - 1);
8397 ids[2] = (nk_draw_index)(index+i);
8404 nk_draw_list_path_clear(
struct nk_draw_list *list)
8409 list->path_count = 0;
8410 list->path_offset = 0;
8414 nk_draw_list_path_line_to(
struct nk_draw_list *list,
struct nk_vec2 pos)
8417 struct nk_draw_command *cmd = 0;
8420 if (!list->cmd_count)
8421 nk_draw_list_add_clip(list, nk_null_rect);
8423 cmd = nk_draw_list_command_last(list);
8424 if (cmd && cmd->texture.ptr != list->config.null.texture.ptr)
8425 nk_draw_list_push_image(list, list->config.null.texture);
8427 points = nk_draw_list_alloc_path(list, 1);
8428 if (!points)
return;
8433 nk_draw_list_path_arc_to_fast(
struct nk_draw_list *list,
struct nk_vec2 center,
8434 float radius,
int a_min,
int a_max)
8439 if (a_min <= a_max) {
8440 for (a = a_min; a <= a_max; a++) {
8442 const float x = center.
x + c.
x * radius;
8443 const float y = center.
y + c.
y * radius;
8444 nk_draw_list_path_line_to(list,
nk_vec2(x, y));
8450 nk_draw_list_path_arc_to(
struct nk_draw_list *list,
struct nk_vec2 center,
8451 float radius,
float a_min,
float a_max,
unsigned int segments)
8456 if (radius == 0.0f)
return;
8457 for (i = 0; i <= segments; ++i) {
8458 const float a = a_min + ((float)i / ((
float)segments) * (a_max - a_min));
8459 const float x = center.x + (
float)NK_COS(a) * radius;
8460 const float y = center.
y + (
float)NK_SIN(a) * radius;
8461 nk_draw_list_path_line_to(list,
nk_vec2(x,
y));
8466 nk_draw_list_path_rect_to(struct nk_draw_list *list, struct
nk_vec2 a,
8467 struct
nk_vec2 b,
float rounding)
8473 r =
NK_MIN(r, ((b.x-a.x) < 0) ? -(b.x-a.x): (b.x-a.x));
8474 r =
NK_MIN(r, ((b.y-a.y) < 0) ? -(b.y-a.y): (b.y-a.y));
8477 nk_draw_list_path_line_to(list, a);
8478 nk_draw_list_path_line_to(list,
nk_vec2(b.x,a.y));
8479 nk_draw_list_path_line_to(list, b);
8480 nk_draw_list_path_line_to(list,
nk_vec2(a.x,b.y));
8482 nk_draw_list_path_arc_to_fast(list,
nk_vec2(a.x + r, a.y + r), r, 6, 9);
8483 nk_draw_list_path_arc_to_fast(list,
nk_vec2(b.x - r, a.y + r), r, 9, 12);
8484 nk_draw_list_path_arc_to_fast(list,
nk_vec2(b.x - r, b.y - r), r, 0, 3);
8485 nk_draw_list_path_arc_to_fast(list,
nk_vec2(a.x + r, b.y - r), r, 3, 6);
8490 nk_draw_list_path_curve_to(
struct nk_draw_list *list,
struct nk_vec2 p2,
8494 unsigned int i_step;
8498 NK_ASSERT(list->path_count);
8499 if (!list || !list->path_count)
return;
8500 num_segments =
NK_MAX(num_segments, 1);
8502 p1 = nk_draw_list_path_last(list);
8503 t_step = 1.0f/(float)num_segments;
8504 for (i_step = 1; i_step <= num_segments; ++i_step) {
8505 float t = t_step * (float)i_step;
8510 float w4 = t * t *t;
8511 float x = w1 * p1.
x + w2 * p2.
x + w3 * p3.
x + w4 * p4.
x;
8512 float y = w1 * p1.
y + w2 * p2.
y + w3 * p3.
y + w4 * p4.
y;
8513 nk_draw_list_path_line_to(list,
nk_vec2(x,y));
8518 nk_draw_list_path_fill(
struct nk_draw_list *list,
struct nk_color color)
8524 nk_draw_list_fill_poly_convex(list, points, list->path_count, color, list->config.shape_AA);
8525 nk_draw_list_path_clear(list);
8529 nk_draw_list_path_stroke(
struct nk_draw_list *list,
struct nk_color color,
8530 enum nk_draw_list_stroke closed,
float thickness)
8536 nk_draw_list_stroke_poly_line(list, points, list->path_count, color,
8537 closed, thickness, list->config.line_AA);
8538 nk_draw_list_path_clear(list);
8542 nk_draw_list_stroke_line(
struct nk_draw_list *list,
struct nk_vec2 a,
8546 if (!list || !col.
a)
return;
8549 nk_draw_list_path_stroke(list, col, NK_STROKE_OPEN, thickness);
8553 nk_draw_list_fill_rect(
struct nk_draw_list *list,
struct nk_rect rect,
8554 struct nk_color col,
float rounding)
8557 if (!list || !col.
a)
return;
8558 nk_draw_list_path_rect_to(list,
nk_vec2(rect.
x + 0.5f, rect.
y + 0.5f),
8559 nk_vec2(rect.
x + rect.
w + 0.5f, rect.
y + rect.
h + 0.5f), rounding);
8560 nk_draw_list_path_fill(list, col);
8564 nk_draw_list_stroke_rect(
struct nk_draw_list *list,
struct nk_rect rect,
8565 struct nk_color col,
float rounding,
float thickness)
8568 if (!list || !col.
a)
return;
8569 nk_draw_list_path_rect_to(list,
nk_vec2(rect.
x + 0.5f, rect.
y + 0.5f),
8570 nk_vec2(rect.
x + rect.
w + 0.5f, rect.
y + rect.
h + 0.5f), rounding);
8571 nk_draw_list_path_stroke(list, col, NK_STROKE_CLOSED, thickness);
8575 nk_draw_list_fill_rect_multi_color(
struct nk_draw_list *list,
struct nk_rect rect,
8583 nk_draw_index index;
8593 nk_draw_list_push_image(list, list->config.null.texture);
8594 index = (nk_draw_index)list->vertex_count;
8595 vtx = nk_draw_list_alloc_vertices(list, 4);
8596 idx = nk_draw_list_alloc_elements(list, 6);
8597 if (!vtx || !idx)
return;
8599 idx[0] = (nk_draw_index)(index+0); idx[1] = (nk_draw_index)(index+1);
8600 idx[2] = (nk_draw_index)(index+2); idx[3] = (nk_draw_index)(index+0);
8601 idx[4] = (nk_draw_index)(index+2); idx[5] = (nk_draw_index)(index+3);
8603 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(rect.
x, rect.
y), list->config.null.uv, col_left);
8604 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(rect.
x + rect.
w, rect.
y), list->config.null.uv, col_top);
8605 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(rect.
x + rect.
w, rect.
y + rect.
h), list->config.null.uv, col_right);
8606 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(rect.
x, rect.
y + rect.
h), list->config.null.uv, col_bottom);
8610 nk_draw_list_fill_triangle(
struct nk_draw_list *list,
struct nk_vec2 a,
8614 if (!list || !col.
a)
return;
8615 nk_draw_list_path_line_to(list, a);
8616 nk_draw_list_path_line_to(list, b);
8617 nk_draw_list_path_line_to(list, c);
8618 nk_draw_list_path_fill(list, col);
8622 nk_draw_list_stroke_triangle(
struct nk_draw_list *list,
struct nk_vec2 a,
8626 if (!list || !col.
a)
return;
8627 nk_draw_list_path_line_to(list, a);
8628 nk_draw_list_path_line_to(list, b);
8629 nk_draw_list_path_line_to(list, c);
8630 nk_draw_list_path_stroke(list, col, NK_STROKE_CLOSED, thickness);
8634 nk_draw_list_fill_circle(
struct nk_draw_list *list,
struct nk_vec2 center,
8635 float radius,
struct nk_color col,
unsigned int segs)
8639 if (!list || !col.
a)
return;
8640 a_max =
NK_PI * 2.0f * ((float)segs - 1.0f) / (float)segs;
8641 nk_draw_list_path_arc_to(list, center, radius, 0.0f, a_max, segs);
8642 nk_draw_list_path_fill(list, col);
8646 nk_draw_list_stroke_circle(
struct nk_draw_list *list,
struct nk_vec2 center,
8647 float radius,
struct nk_color col,
unsigned int segs,
float thickness)
8651 if (!list || !col.
a)
return;
8652 a_max =
NK_PI * 2.0f * ((float)segs - 1.0f) / (float)segs;
8653 nk_draw_list_path_arc_to(list, center, radius, 0.0f, a_max, segs);
8654 nk_draw_list_path_stroke(list, col, NK_STROKE_CLOSED, thickness);
8658 nk_draw_list_stroke_curve(
struct nk_draw_list *list,
struct nk_vec2 p0,
8660 struct nk_color col,
unsigned int segments,
float thickness)
8663 if (!list || !col.
a)
return;
8664 nk_draw_list_path_line_to(list, p0);
8665 nk_draw_list_path_curve_to(list, cp0, cp1, p1, segments);
8666 nk_draw_list_path_stroke(list, col, NK_STROKE_OPEN, thickness);
8670 nk_draw_list_push_rect_uv(
struct nk_draw_list *list,
struct nk_vec2 a,
8682 nk_draw_index index;
8692 index = (nk_draw_index)list->vertex_count;
8693 vtx = nk_draw_list_alloc_vertices(list, 4);
8694 idx = nk_draw_list_alloc_elements(list, 6);
8695 if (!vtx || !idx)
return;
8697 idx[0] = (nk_draw_index)(index+0); idx[1] = (nk_draw_index)(index+1);
8698 idx[2] = (nk_draw_index)(index+2); idx[3] = (nk_draw_index)(index+0);
8699 idx[4] = (nk_draw_index)(index+2); idx[5] = (nk_draw_index)(index+3);
8701 vtx = nk_draw_vertex(vtx, &list->config, a, uva, col);
8702 vtx = nk_draw_vertex(vtx, &list->config, b, uvb, col);
8703 vtx = nk_draw_vertex(vtx, &list->config, c, uvc, col);
8704 vtx = nk_draw_vertex(vtx, &list->config, d, uvd, col);
8708 nk_draw_list_add_image(
struct nk_draw_list *list,
struct nk_image texture,
8714 nk_draw_list_push_image(list, texture.
handle);
8718 uv[0].
x = (float)texture.
region[0]/(
float)texture.
w;
8719 uv[0].
y = (float)texture.
region[1]/(
float)texture.
h;
8720 uv[1].
x = (float)(texture.
region[0] + texture.
region[2])/(float)texture.
w;
8721 uv[1].
y = (
float)(texture.
region[1] + texture.
region[3])/(
float)texture.
h;
8722 nk_draw_list_push_rect_uv(list,
nk_vec2(rect.
x, rect.
y),
8723 nk_vec2(rect.
x + rect.
w, rect.
y + rect.
h), uv[0], uv[1], color);
8724 }
else nk_draw_list_push_rect_uv(list,
nk_vec2(rect.
x, rect.
y),
8730 nk_draw_list_add_text(
struct nk_draw_list *list,
const struct nk_user_font *font,
8731 struct nk_rect rect,
const char *text,
int len,
float font_height,
8736 nk_rune unicode = 0;
8739 int next_glyph_len = 0;
8740 struct nk_user_font_glyph g;
8743 if (!list || !len || !text)
return;
8745 list->clip_rect.x, list->clip_rect.y, list->clip_rect.w, list->clip_rect.h))
return;
8747 nk_draw_list_push_image(list, font->texture);
8750 if (!glyph_len)
return;
8753 fg.
a = (
nk_byte)((
float)fg.
a * list->config.global_alpha);
8754 while (text_len < len && glyph_len) {
8755 float gx, gy, gh, gw;
8756 float char_width = 0;
8760 next_glyph_len =
nk_utf_decode(text + text_len + glyph_len, &next, (
int)len - text_len);
8761 font->query(font->
userdata, font_height, &g, unicode,
8765 gx = x + g.offset.x;
8766 gy = rect.
y + g.offset.y;
8767 gw = g.width; gh = g.height;
8768 char_width = g.xadvance;
8769 nk_draw_list_push_rect_uv(list,
nk_vec2(gx,gy),
nk_vec2(gx + gw, gy+ gh),
8770 g.uv[0], g.uv[1], fg);
8773 text_len += glyph_len;
8775 glyph_len = next_glyph_len;
8789 NK_ASSERT(vertices);
8790 NK_ASSERT(elements);
8794 if (!ctx || !cmds || !vertices || !elements || !config || !config->
vertex_layout)
8797 nk_draw_list_setup(&ctx->draw_list, config, cmds, vertices, elements);
8800 #ifdef NK_INCLUDE_COMMAND_USERDATA
8801 ctx->draw_list.userdata = cmd->userdata;
8803 switch (cmd->
type) {
8807 nk_draw_list_add_clip(&ctx->draw_list,
nk_rect(s->
x, s->
y, s->
w, s->
h));
8823 nk_draw_list_stroke_rect(&ctx->draw_list,
nk_rect(r->
x, r->
y, r->
w, r->
h),
8828 nk_draw_list_fill_rect(&ctx->draw_list,
nk_rect(r->
x, r->
y, r->
w, r->
h),
8833 nk_draw_list_fill_rect_multi_color(&ctx->draw_list,
nk_rect(r->
x, r->
y, r->
w, r->
h),
8838 nk_draw_list_stroke_circle(&ctx->draw_list,
nk_vec2((
float)c->
x + (
float)c->
w/2,
8839 (
float)c->
y + (
float)c->
h/2), (
float)c->
w/2, c->
color,
8844 nk_draw_list_fill_circle(&ctx->draw_list,
nk_vec2((
float)c->
x + (
float)c->
w/2,
8845 (
float)c->
y + (
float)c->
h/2), (
float)c->
w/2, c->
color,
8850 nk_draw_list_path_line_to(&ctx->draw_list,
nk_vec2(c->
cx, c->
cy));
8851 nk_draw_list_path_arc_to(&ctx->draw_list,
nk_vec2(c->
cx, c->
cy), c->
r,
8857 nk_draw_list_path_line_to(&ctx->draw_list,
nk_vec2(c->
cx, c->
cy));
8858 nk_draw_list_path_arc_to(&ctx->draw_list,
nk_vec2(c->
cx, c->
cy), c->
r,
8860 nk_draw_list_path_fill(&ctx->draw_list, c->
color);
8864 nk_draw_list_stroke_triangle(&ctx->draw_list,
nk_vec2(t->
a.
x, t->
a.
y),
8870 nk_draw_list_fill_triangle(&ctx->draw_list,
nk_vec2(t->
a.
x, t->
a.
y),
8878 nk_draw_list_path_line_to(&ctx->draw_list, pnt);
8887 nk_draw_list_path_line_to(&ctx->draw_list, pnt);
8889 nk_draw_list_path_fill(&ctx->draw_list, p->
color);
8896 nk_draw_list_path_line_to(&ctx->draw_list, pnt);
8902 nk_draw_list_add_text(&ctx->draw_list, t->
font,
nk_rect(t->
x, t->
y, t->
w, t->
h),
8907 nk_draw_list_add_image(&ctx->draw_list, i->
img,
nk_rect(i->
x, i->
y, i->
w, i->
h), i->
col);
8921 NK_API const struct nk_draw_command*
8924 {
return nk__draw_list_begin(&ctx->draw_list, buffer);}
8926 NK_API const struct nk_draw_command*
8928 {
return nk__draw_list_end(&ctx->draw_list, buffer);}
8930 NK_API const struct nk_draw_command*
8931 nk__draw_next(
const struct nk_draw_command *cmd,
8933 {
return nk__draw_list_next(cmd, buffer, &ctx->draw_list);}
8944 #ifdef NK_INCLUDE_FONT_BAKING
8952 #define NK_RP__MAXVAL 0xffff
8953 typedef unsigned short nk_rp_coord;
8968 struct nk_rp_node *next;
8971 struct nk_rp_context {
8978 struct nk_rp_node *active_head;
8979 struct nk_rp_node *free_head;
8980 struct nk_rp_node extra[2];
8984 struct nk_rp__findresult {
8986 struct nk_rp_node **prev_link;
8989 enum NK_RP_HEURISTIC {
8990 NK_RP_HEURISTIC_Skyline_default=0,
8991 NK_RP_HEURISTIC_Skyline_BL_sortHeight = NK_RP_HEURISTIC_Skyline_default,
8992 NK_RP_HEURISTIC_Skyline_BF_sortHeight
8994 enum NK_RP_INIT_STATE{NK_RP__INIT_skyline = 1};
8997 nk_rp_setup_allow_out_of_mem(
struct nk_rp_context *context,
int allow_out_of_mem)
8999 if (allow_out_of_mem)
9012 context->align = (context->width + context->num_nodes-1) / context->num_nodes;
9017 nk_rp_init_target(
struct nk_rp_context *context,
int width,
int height,
9018 struct nk_rp_node *nodes,
int num_nodes)
9021 #ifndef STBRP_LARGE_RECTS
9022 NK_ASSERT(width <= 0xffff && height <= 0xffff);
9025 for (i=0; i < num_nodes-1; ++i)
9026 nodes[i].next = &nodes[i+1];
9028 context->init_mode = NK_RP__INIT_skyline;
9029 context->heuristic = NK_RP_HEURISTIC_Skyline_default;
9030 context->free_head = &nodes[0];
9031 context->active_head = &context->extra[0];
9032 context->width = width;
9033 context->height = height;
9034 context->num_nodes = num_nodes;
9035 nk_rp_setup_allow_out_of_mem(context, 0);
9038 context->extra[0].x = 0;
9039 context->extra[0].y = 0;
9040 context->extra[0].next = &context->extra[1];
9041 context->extra[1].x = (nk_rp_coord) width;
9042 context->extra[1].y = 65535;
9043 context->extra[1].next = 0;
9048 nk_rp__skyline_find_min_y(
struct nk_rp_context *c,
struct nk_rp_node *first,
9049 int x0,
int width,
int *pwaste)
9051 struct nk_rp_node *node = first;
9052 int x1 = x0 + width;
9053 int min_y, visited_width, waste_area;
9054 NK_ASSERT(first->x <= x0);
9057 NK_ASSERT(node->next->x > x0);
9059 NK_ASSERT(node->x <= x0);
9064 while (node->x < x1)
9066 if (node->y > min_y) {
9070 waste_area += visited_width * (node->y - min_y);
9074 visited_width += node->next->x - x0;
9076 visited_width += node->next->x - node->x;
9079 int under_width = node->next->x - node->x;
9080 if (under_width + visited_width > width)
9081 under_width = width - visited_width;
9082 waste_area += under_width * (min_y - node->y);
9083 visited_width += under_width;
9087 *pwaste = waste_area;
9092 nk_rp__skyline_find_best_pos(struct nk_rp_context *c,
int width,
int height)
9094 int best_waste = (1<<30), best_x, best_y = (1 << 30);
9095 struct nk_rp__findresult fr;
9096 struct nk_rp_node **prev, *node, *tail, **best = 0;
9099 width = (width + c->align - 1);
9100 width -= width % c->align;
9101 NK_ASSERT(width % c->align == 0);
9103 node = c->active_head;
9104 prev = &c->active_head;
9105 while (node->x + width <= c->width) {
9107 y = nk_rp__skyline_find_min_y(c, node, node->x, width, &waste);
9109 if (c->heuristic == NK_RP_HEURISTIC_Skyline_BL_sortHeight) {
9117 if (y + height <= c->height) {
9119 if (y < best_y || (y == best_y && waste < best_waste)) {
9129 best_x = (best == 0) ? 0 : (*best)->x;
9147 if (c->heuristic == NK_RP_HEURISTIC_Skyline_BF_sortHeight)
9149 tail = c->active_head;
9150 node = c->active_head;
9151 prev = &c->active_head;
9153 while (tail->x < width)
9157 int xpos = tail->x - width;
9159 NK_ASSERT(xpos >= 0);
9161 while (node->next->x <= xpos) {
9165 NK_ASSERT(node->next->x > xpos && node->x <= xpos);
9166 y = nk_rp__skyline_find_min_y(c, node, xpos, width, &waste);
9167 if (y + height < c->height) {
9169 if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) {
9171 NK_ASSERT(y <= best_y);
9181 fr.prev_link = best;
9188 nk_rp__skyline_pack_rectangle(struct nk_rp_context *context,
int width,
int height)
9191 struct nk_rp__findresult res = nk_rp__skyline_find_best_pos(context, width, height);
9192 struct nk_rp_node *node, *cur;
9198 if (res.prev_link == 0 || res.y + height > context->height || context->free_head == 0) {
9204 node = context->free_head;
9205 node->x = (nk_rp_coord) res.x;
9206 node->y = (nk_rp_coord) (res.y + height);
9208 context->free_head = node->next;
9213 cur = *res.prev_link;
9214 if (cur->x < res.x) {
9216 struct nk_rp_node *next = cur->next;
9220 *res.prev_link = node;
9225 while (cur->next && cur->next->x <= res.x + width) {
9226 struct nk_rp_node *next = cur->next;
9228 cur->next = context->free_head;
9229 context->free_head = cur;
9235 if (cur->x < res.x + width)
9236 cur->x = (nk_rp_coord) (res.x + width);
9241 nk_rect_height_compare(
const void *a,
const void *b)
9243 const struct nk_rp_rect *p = (
const struct nk_rp_rect *) a;
9244 const struct nk_rp_rect *q = (
const struct nk_rp_rect *) b;
9249 return (p->w > q->w) ? -1 : (p->w < q->w);
9253 nk_rect_original_order(
const void *a,
const void *b)
9255 const struct nk_rp_rect *p = (
const struct nk_rp_rect *) a;
9256 const struct nk_rp_rect *q = (
const struct nk_rp_rect *) b;
9257 return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed);
9261 nk_rp_qsort(
struct nk_rp_rect *array,
unsigned int len,
int(*cmp)(
const void*,
const void*))
9264 #define NK_MAX_SORT_STACK 64
9265 unsigned right, left = 0, stack[NK_MAX_SORT_STACK], pos = 0;
9266 unsigned seed = len/2 * 69069+1;
9268 for (; left+1 < len; len++) {
9269 struct nk_rp_rect pivot, tmp;
9270 if (pos == NK_MAX_SORT_STACK) len = stack[pos = 0];
9271 pivot = array[left+seed%(len-left)];
9272 seed = seed * 69069 + 1;
9274 for (right = left-1;;) {
9275 while (cmp(&array[++right], &pivot) < 0);
9276 while (cmp(&pivot, &array[--len]) < 0);
9277 if (right >= len)
break;
9279 array[right] = array[len];
9283 if (pos == 0)
break;
9287 #undef NK_MAX_SORT_STACK
9291 nk_rp_pack_rects(
struct nk_rp_context *context,
struct nk_rp_rect *rects,
int num_rects)
9295 for (i=0; i < num_rects; ++i) {
9296 rects[i].was_packed = i;
9300 nk_rp_qsort(rects, (
unsigned)num_rects, nk_rect_height_compare);
9302 for (i=0; i < num_rects; ++i) {
9303 struct nk_rp__findresult fr = nk_rp__skyline_pack_rectangle(context, rects[i].w, rects[i].h);
9305 rects[i].x = (nk_rp_coord) fr.x;
9306 rects[i].y = (nk_rp_coord) fr.y;
9308 rects[i].x = rects[i].y = NK_RP__MAXVAL;
9313 nk_rp_qsort(rects, (
unsigned)num_rects, nk_rect_original_order);
9316 for (i=0; i < num_rects; ++i)
9317 rects[i].was_packed = !(rects[i].x == NK_RP__MAXVAL && rects[i].y == NK_RP__MAXVAL);
9328 #define NK_TT_MAX_OVERSAMPLE 8
9329 #define NK_TT__OVER_MASK (NK_TT_MAX_OVERSAMPLE-1)
9331 struct nk_tt_bakedchar {
9332 unsigned short x0,y0,x1,y1;
9334 float xoff,yoff,xadvance;
9337 struct nk_tt_aligned_quad{
9342 struct nk_tt_packedchar {
9343 unsigned short x0,y0,x1,y1;
9345 float xoff,yoff,xadvance;
9349 struct nk_tt_pack_range {
9351 int first_unicode_codepoint_in_range;
9353 int *array_of_unicode_codepoints;
9356 struct nk_tt_packedchar *chardata_for_range;
9357 unsigned char h_oversample, v_oversample;
9361 struct nk_tt_pack_context {
9365 int stride_in_bytes;
9367 unsigned int h_oversample, v_oversample;
9368 unsigned char *pixels;
9372 struct nk_tt_fontinfo {
9373 const unsigned char* data;
9376 int loca,head,glyf,hhea,hmtx,kern;
9378 int indexToLocFormat;
9387 struct nk_tt_vertex {
9389 unsigned char type,padding;
9392 struct nk_tt__bitmap{
9394 unsigned char *pixels;
9397 struct nk_tt__hheap_chunk {
9398 struct nk_tt__hheap_chunk *next;
9400 struct nk_tt__hheap {
9402 struct nk_tt__hheap_chunk *head;
9404 int num_remaining_in_head_chunk;
9407 struct nk_tt__edge {
9412 struct nk_tt__active_edge {
9413 struct nk_tt__active_edge *next;
9419 struct nk_tt__point {
float x,y;};
9421 #define NK_TT_MACSTYLE_DONTCARE 0
9422 #define NK_TT_MACSTYLE_BOLD 1
9423 #define NK_TT_MACSTYLE_ITALIC 2
9424 #define NK_TT_MACSTYLE_UNDERSCORE 4
9425 #define NK_TT_MACSTYLE_NONE 8
9429 NK_TT_PLATFORM_ID_UNICODE =0,
9430 NK_TT_PLATFORM_ID_MAC =1,
9431 NK_TT_PLATFORM_ID_ISO =2,
9432 NK_TT_PLATFORM_ID_MICROSOFT =3
9436 NK_TT_UNICODE_EID_UNICODE_1_0 =0,
9437 NK_TT_UNICODE_EID_UNICODE_1_1 =1,
9438 NK_TT_UNICODE_EID_ISO_10646 =2,
9439 NK_TT_UNICODE_EID_UNICODE_2_0_BMP=3,
9440 NK_TT_UNICODE_EID_UNICODE_2_0_FULL=4
9444 NK_TT_MS_EID_SYMBOL =0,
9445 NK_TT_MS_EID_UNICODE_BMP =1,
9446 NK_TT_MS_EID_SHIFTJIS =2,
9447 NK_TT_MS_EID_UNICODE_FULL =10
9451 NK_TT_MAC_EID_ROMAN =0, NK_TT_MAC_EID_ARABIC =4,
9452 NK_TT_MAC_EID_JAPANESE =1, NK_TT_MAC_EID_HEBREW =5,
9453 NK_TT_MAC_EID_CHINESE_TRAD =2, NK_TT_MAC_EID_GREEK =6,
9454 NK_TT_MAC_EID_KOREAN =3, NK_TT_MAC_EID_RUSSIAN =7
9459 NK_TT_MS_LANG_ENGLISH =0x0409, NK_TT_MS_LANG_ITALIAN =0x0410,
9460 NK_TT_MS_LANG_CHINESE =0x0804, NK_TT_MS_LANG_JAPANESE =0x0411,
9461 NK_TT_MS_LANG_DUTCH =0x0413, NK_TT_MS_LANG_KOREAN =0x0412,
9462 NK_TT_MS_LANG_FRENCH =0x040c, NK_TT_MS_LANG_RUSSIAN =0x0419,
9463 NK_TT_MS_LANG_GERMAN =0x0407, NK_TT_MS_LANG_SPANISH =0x0409,
9464 NK_TT_MS_LANG_HEBREW =0x040d, NK_TT_MS_LANG_SWEDISH =0x041D
9468 NK_TT_MAC_LANG_ENGLISH =0 , NK_TT_MAC_LANG_JAPANESE =11,
9469 NK_TT_MAC_LANG_ARABIC =12, NK_TT_MAC_LANG_KOREAN =23,
9470 NK_TT_MAC_LANG_DUTCH =4 , NK_TT_MAC_LANG_RUSSIAN =32,
9471 NK_TT_MAC_LANG_FRENCH =1 , NK_TT_MAC_LANG_SPANISH =6 ,
9472 NK_TT_MAC_LANG_GERMAN =2 , NK_TT_MAC_LANG_SWEDISH =5 ,
9473 NK_TT_MAC_LANG_HEBREW =10, NK_TT_MAC_LANG_CHINESE_SIMPLIFIED =33,
9474 NK_TT_MAC_LANG_ITALIAN =3 , NK_TT_MAC_LANG_CHINESE_TRAD =19
9477 #define nk_ttBYTE(p) (* (const nk_byte *) (p))
9478 #define nk_ttCHAR(p) (* (const char *) (p))
9480 #if defined(NK_BIGENDIAN) && !defined(NK_ALLOW_UNALIGNED_TRUETYPE)
9481 #define nk_ttUSHORT(p) (* (nk_ushort *) (p))
9482 #define nk_ttSHORT(p) (* (nk_short *) (p))
9483 #define nk_ttULONG(p) (* (nk_uint *) (p))
9484 #define nk_ttLONG(p) (* (nk_int *) (p))
9486 static nk_ushort nk_ttUSHORT(
const nk_byte *p) {
return (nk_ushort)(p[0]*256 + p[1]); }
9487 static nk_short nk_ttSHORT(
const nk_byte *p) {
return (nk_short)(p[0]*256 + p[1]); }
9488 static nk_uint nk_ttULONG(
const nk_byte *p) {
return (nk_uint)((p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]); }
9491 #define nk_tt_tag4(p,c0,c1,c2,c3)\
9492 ((p)[0] == (c0) && (p)[1] == (c1) && (p)[2] == (c2) && (p)[3] == (c3))
9493 #define nk_tt_tag(p,str) nk_tt_tag4(p,str[0],str[1],str[2],str[3])
9496 int glyph_index,
struct nk_tt_vertex **pvertices);
9499 nk_tt__find_table(
const nk_byte *data, nk_uint fontstart,
const char *tag)
9502 nk_int num_tables = nk_ttUSHORT(data+fontstart+4);
9503 nk_uint tabledir = fontstart + 12;
9505 for (i = 0; i < num_tables; ++i) {
9506 nk_uint loc = tabledir + (
nk_uint)(16*i);
9507 if (nk_tt_tag(data+loc+0, tag))
9508 return nk_ttULONG(data+loc+8);
9514 nk_tt_InitFont(
struct nk_tt_fontinfo *info,
const unsigned char *data2,
int fontstart)
9518 const nk_byte *data = (
const nk_byte *) data2;
9521 info->fontstart = fontstart;
9523 cmap = nk_tt__find_table(data, (nk_uint)fontstart,
"cmap");
9524 info->loca = (
int)nk_tt__find_table(data, (nk_uint)fontstart,
"loca");
9525 info->head = (
int)nk_tt__find_table(data, (nk_uint)fontstart,
"head");
9526 info->glyf = (
int)nk_tt__find_table(data, (nk_uint)fontstart,
"glyf");
9527 info->hhea = (
int)nk_tt__find_table(data, (nk_uint)fontstart,
"hhea");
9528 info->hmtx = (
int)nk_tt__find_table(data, (nk_uint)fontstart,
"hmtx");
9529 info->kern = (
int)nk_tt__find_table(data, (nk_uint)fontstart,
"kern");
9530 if (!cmap || !info->loca || !info->head || !info->glyf || !info->hhea || !info->hmtx)
9533 t = nk_tt__find_table(data, (nk_uint)fontstart,
"maxp");
9534 if (t) info->numGlyphs = nk_ttUSHORT(data+t+4);
9535 else info->numGlyphs = 0xffff;
9540 numTables = nk_ttUSHORT(data + cmap + 2);
9541 info->index_map = 0;
9542 for (i=0; i < numTables; ++i)
9544 nk_uint encoding_record = cmap + 4 + 8 * (
nk_uint)i;
9546 switch(nk_ttUSHORT(data+encoding_record)) {
9547 case NK_TT_PLATFORM_ID_MICROSOFT:
9548 switch (nk_ttUSHORT(data+encoding_record+2)) {
9549 case NK_TT_MS_EID_UNICODE_BMP:
9550 case NK_TT_MS_EID_UNICODE_FULL:
9552 info->index_map = (
int)(cmap + nk_ttULONG(data+encoding_record+4));
9556 case NK_TT_PLATFORM_ID_UNICODE:
9559 info->index_map = (
int)(cmap + nk_ttULONG(data+encoding_record+4));
9564 if (info->index_map == 0)
9566 info->indexToLocFormat = nk_ttUSHORT(data+info->head + 50);
9571 nk_tt_FindGlyphIndex(
const struct nk_tt_fontinfo *info,
int unicode_codepoint)
9573 const nk_byte *data = info->data;
9574 nk_uint index_map = (
nk_uint)info->index_map;
9576 nk_ushort format = nk_ttUSHORT(data + index_map + 0);
9578 nk_int bytes = nk_ttUSHORT(data + index_map + 2);
9579 if (unicode_codepoint < bytes-6)
9580 return nk_ttBYTE(data + index_map + 6 + unicode_codepoint);
9582 }
else if (format == 6) {
9583 nk_uint first = nk_ttUSHORT(data + index_map + 6);
9584 nk_uint count = nk_ttUSHORT(data + index_map + 8);
9585 if ((nk_uint) unicode_codepoint >= first && (nk_uint) unicode_codepoint < first+count)
9586 return nk_ttUSHORT(data + index_map + 10 + (unicode_codepoint - (
int)first)*2);
9588 }
else if (format == 2) {
9591 }
else if (format == 4) {
9592 nk_ushort segcount = nk_ttUSHORT(data+index_map+6) >> 1;
9593 nk_ushort searchRange = nk_ttUSHORT(data+index_map+8) >> 1;
9594 nk_ushort entrySelector = nk_ttUSHORT(data+index_map+10);
9595 nk_ushort rangeShift = nk_ttUSHORT(data+index_map+12) >> 1;
9598 nk_uint endCount = index_map + 14;
9599 nk_uint search = endCount;
9601 if (unicode_codepoint > 0xffff)
9606 if (unicode_codepoint >= nk_ttUSHORT(data + search + rangeShift*2))
9607 search += (
nk_uint)(rangeShift*2);
9611 while (entrySelector) {
9614 end = nk_ttUSHORT(data + search + searchRange*2);
9615 if (unicode_codepoint > end)
9616 search += (
nk_uint)(searchRange*2);
9622 nk_ushort offset, start;
9623 nk_ushort item = (
nk_ushort) ((search - endCount) >> 1);
9625 NK_ASSERT(unicode_codepoint <= nk_ttUSHORT(data + endCount + 2*item));
9626 start = nk_ttUSHORT(data + index_map + 14 + segcount*2 + 2 + 2*item);
9627 if (unicode_codepoint < start)
9630 offset = nk_ttUSHORT(data + index_map + 14 + segcount*6 + 2 + 2*item);
9632 return (nk_ushort) (unicode_codepoint + nk_ttSHORT(data + index_map + 14 + segcount*4 + 2 + 2*item));
9634 return nk_ttUSHORT(data + offset + (unicode_codepoint-start)*2 + index_map + 14 + segcount*6 + 2 + 2*item);
9636 }
else if (format == 12 || format == 13) {
9637 nk_uint ngroups = nk_ttULONG(data+index_map+12);
9639 low = 0; high = (
nk_int)ngroups;
9641 while (low < high) {
9642 nk_int mid = low + ((high-low) >> 1);
9643 nk_uint start_char = nk_ttULONG(data+index_map+16+mid*12);
9644 nk_uint end_char = nk_ttULONG(data+index_map+16+mid*12+4);
9645 if ((nk_uint) unicode_codepoint < start_char)
9647 else if ((nk_uint) unicode_codepoint > end_char)
9650 nk_uint start_glyph = nk_ttULONG(data+index_map+16+mid*12+8);
9652 return (
int)start_glyph + (
int)unicode_codepoint - (
int)start_char;
9654 return (
int)start_glyph;
9665 nk_tt_setvertex(struct nk_tt_vertex *v, nk_byte type, nk_int x, nk_int y, nk_int cx, nk_int cy)
9675 nk_tt__GetGlyfOffset(
const struct nk_tt_fontinfo *info,
int glyph_index)
9678 if (glyph_index >= info->numGlyphs)
return -1;
9679 if (info->indexToLocFormat >= 2)
return -1;
9681 if (info->indexToLocFormat == 0) {
9682 g1 = info->glyf + nk_ttUSHORT(info->data + info->loca + glyph_index * 2) * 2;
9683 g2 = info->glyf + nk_ttUSHORT(info->data + info->loca + glyph_index * 2 + 2) * 2;
9685 g1 = info->glyf + (
int)nk_ttULONG (info->data + info->loca + glyph_index * 4);
9686 g2 = info->glyf + (
int)nk_ttULONG (info->data + info->loca + glyph_index * 4 + 4);
9688 return g1==g2 ? -1 : g1;
9692 nk_tt_GetGlyphBox(
const struct nk_tt_fontinfo *info,
int glyph_index,
9693 int *x0,
int *y0,
int *x1,
int *y1)
9695 int g = nk_tt__GetGlyfOffset(info, glyph_index);
9696 if (g < 0)
return 0;
9698 if (x0) *x0 = nk_ttSHORT(info->data + g + 2);
9699 if (y0) *y0 = nk_ttSHORT(info->data + g + 4);
9700 if (x1) *x1 = nk_ttSHORT(info->data + g + 6);
9701 if (y1) *y1 = nk_ttSHORT(info->data + g + 8);
9706 stbtt__close_shape(
struct nk_tt_vertex *vertices,
int num_vertices,
int was_off,
9707 int start_off, nk_int sx, nk_int sy, nk_int scx, nk_int scy, nk_int cx, nk_int cy)
9711 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vcurve, (cx+scx)>>1, (cy+scy)>>1, cx,cy);
9712 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vcurve, sx,sy,scx,scy);
9715 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vcurve,sx,sy,cx,cy);
9717 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vline,sx,sy,0,0);
9719 return num_vertices;
9723 nk_tt_GetGlyphShape(
const struct nk_tt_fontinfo *info,
struct nk_allocator *alloc,
9724 int glyph_index,
struct nk_tt_vertex **pvertices)
9726 nk_short numberOfContours;
9727 const nk_byte *endPtsOfContours;
9728 const nk_byte *data = info->data;
9729 struct nk_tt_vertex *vertices=0;
9731 int g = nk_tt__GetGlyfOffset(info, glyph_index);
9734 if (g < 0)
return 0;
9735 numberOfContours = nk_ttSHORT(data + g);
9736 if (numberOfContours > 0) {
9737 nk_byte flags=0,flagcount;
9738 nk_int ins, i,j=0,
m,n, next_move, was_off=0, off, start_off=0;
9739 nk_int x,y,cx,cy,sx,sy, scx,scy;
9740 const nk_byte *points;
9741 endPtsOfContours = (data + g + 10);
9742 ins = nk_ttUSHORT(data + g + 10 + numberOfContours * 2);
9743 points = data + g + 10 + numberOfContours * 2 + 2 + ins;
9745 n = 1+nk_ttUSHORT(endPtsOfContours + numberOfContours*2-2);
9746 m = n + 2*numberOfContours;
9747 vertices = (
struct nk_tt_vertex *)alloc->
alloc(alloc->
userdata, 0, (nk_size)m *
sizeof(vertices[0]));
9760 for (i=0; i < n; ++i) {
9761 if (flagcount == 0) {
9764 flagcount = *points++;
9766 vertices[off+i].type = flags;
9771 for (i=0; i < n; ++i) {
9772 flags = vertices[off+i].type;
9774 nk_short dx = *points++;
9775 x += (flags & 16) ? dx : -dx;
9777 if (!(flags & 16)) {
9778 x = x + (
nk_short) (points[0]*256 + points[1]);
9787 for (i=0; i < n; ++i) {
9788 flags = vertices[off+i].type;
9790 nk_short dy = *points++;
9791 y += (flags & 32) ? dy : -dy;
9793 if (!(flags & 32)) {
9794 y = y + (
nk_short) (points[0]*256 + points[1]);
9803 sx = sy = cx = cy = scx = scy = 0;
9804 for (i=0; i < n; ++i)
9806 flags = vertices[off+i].type;
9810 if (next_move == i) {
9812 num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy);
9815 start_off = !(flags & 1);
9821 if (!(vertices[off+i+1].type & 1)) {
9823 sx = (x + (
nk_int) vertices[off+i+1].x) >> 1;
9824 sy = (y + (
nk_int) vertices[off+i+1].y) >> 1;
9827 sx = (
nk_int) vertices[off+i+1].x;
9828 sy = (
nk_int) vertices[off+i+1].y;
9835 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vmove,sx,sy,0,0);
9837 next_move = 1 + nk_ttUSHORT(endPtsOfContours+j*2);
9843 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vcurve, (cx+x)>>1, (cy+y)>>1, cx, cy);
9849 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vcurve, x,y, cx, cy);
9850 else nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vline, x,y,0,0);
9855 num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy);
9856 }
else if (numberOfContours == -1) {
9859 const nk_byte *comp = data + g + 10;
9865 nk_ushort flags, gidx;
9866 int comp_num_verts = 0, i;
9867 struct nk_tt_vertex *comp_verts = 0, *tmp = 0;
9868 float mtx[6] = {1,0,0,1,0,0},
m, n;
9870 flags = (
nk_ushort)nk_ttSHORT(comp); comp+=2;
9871 gidx = (
nk_ushort)nk_ttSHORT(comp); comp+=2;
9875 mtx[4] = nk_ttSHORT(comp); comp+=2;
9876 mtx[5] = nk_ttSHORT(comp); comp+=2;
9878 mtx[4] = nk_ttCHAR(comp); comp+=1;
9879 mtx[5] = nk_ttCHAR(comp); comp+=1;
9885 if (flags & (1<<3)) {
9886 mtx[0] = mtx[3] = nk_ttSHORT(comp)/16384.0f; comp+=2;
9887 mtx[1] = mtx[2] = 0;
9888 }
else if (flags & (1<<6)) {
9889 mtx[0] = nk_ttSHORT(comp)/16384.0f; comp+=2;
9890 mtx[1] = mtx[2] = 0;
9891 mtx[3] = nk_ttSHORT(comp)/16384.0f; comp+=2;
9892 }
else if (flags & (1<<7)) {
9893 mtx[0] = nk_ttSHORT(comp)/16384.0f; comp+=2;
9894 mtx[1] = nk_ttSHORT(comp)/16384.0f; comp+=2;
9895 mtx[2] = nk_ttSHORT(comp)/16384.0f; comp+=2;
9896 mtx[3] = nk_ttSHORT(comp)/16384.0f; comp+=2;
9900 m = (float) NK_SQRT(mtx[0]*mtx[0] + mtx[1]*mtx[1]);
9901 n = (float) NK_SQRT(mtx[2]*mtx[2] + mtx[3]*mtx[3]);
9904 comp_num_verts = nk_tt_GetGlyphShape(info, alloc, gidx, &comp_verts);
9905 if (comp_num_verts > 0)
9908 for (i = 0; i < comp_num_verts; ++i) {
9909 struct nk_tt_vertex* v = &comp_verts[i];
9912 v->x = (short)(m * (mtx[0]*x + mtx[2]*y + mtx[4]));
9913 v->y = (short)(n * (mtx[1]*x + mtx[3]*y + mtx[5]));
9915 v->cx = (short)(m * (mtx[0]*x + mtx[2]*y + mtx[4]));
9916 v->cy = (short)(n * (mtx[1]*x + mtx[3]*y + mtx[5]));
9919 tmp = (
struct nk_tt_vertex*)alloc->
alloc(alloc->
userdata, 0,
9920 (nk_size)(num_vertices+comp_num_verts)*
sizeof(
struct nk_tt_vertex));
9923 if (comp_verts) alloc->
free(alloc->
userdata, comp_verts);
9926 if (num_vertices > 0) NK_MEMCPY(tmp, vertices, (nk_size)num_vertices*
sizeof(
struct nk_tt_vertex));
9927 NK_MEMCPY(tmp+num_vertices, comp_verts, (nk_size)comp_num_verts*
sizeof(
struct nk_tt_vertex));
9931 num_vertices += comp_num_verts;
9934 more = flags & (1<<5);
9936 }
else if (numberOfContours < 0) {
9942 *pvertices = vertices;
9943 return num_vertices;
9947 nk_tt_GetGlyphHMetrics(
const struct nk_tt_fontinfo *info,
int glyph_index,
9948 int *advanceWidth,
int *leftSideBearing)
9950 nk_ushort numOfLongHorMetrics = nk_ttUSHORT(info->data+info->hhea + 34);
9951 if (glyph_index < numOfLongHorMetrics) {
9953 *advanceWidth = nk_ttSHORT(info->data + info->hmtx + 4*glyph_index);
9954 if (leftSideBearing)
9955 *leftSideBearing = nk_ttSHORT(info->data + info->hmtx + 4*glyph_index + 2);
9958 *advanceWidth = nk_ttSHORT(info->data + info->hmtx + 4*(numOfLongHorMetrics-1));
9959 if (leftSideBearing)
9960 *leftSideBearing = nk_ttSHORT(info->data + info->hmtx + 4*numOfLongHorMetrics + 2*(glyph_index - numOfLongHorMetrics));
9965 nk_tt_GetFontVMetrics(
const struct nk_tt_fontinfo *info,
9966 int *ascent,
int *descent,
int *lineGap)
9968 if (ascent ) *ascent = nk_ttSHORT(info->data+info->hhea + 4);
9969 if (descent) *descent = nk_ttSHORT(info->data+info->hhea + 6);
9970 if (lineGap) *lineGap = nk_ttSHORT(info->data+info->hhea + 8);
9974 nk_tt_ScaleForPixelHeight(
const struct nk_tt_fontinfo *info,
float height)
9976 int fheight = nk_ttSHORT(info->data + info->hhea + 4) - nk_ttSHORT(info->data + info->hhea + 6);
9977 return (
float) height / (float)fheight;
9981 nk_tt_ScaleForMappingEmToPixels(
const struct nk_tt_fontinfo *info,
float pixels)
9983 int unitsPerEm = nk_ttUSHORT(info->data + info->head + 18);
9984 return pixels / (float)unitsPerEm;
9991 nk_tt_GetGlyphBitmapBoxSubpixel(
const struct nk_tt_fontinfo *font,
9992 int glyph,
float scale_x,
float scale_y,
float shift_x,
float shift_y,
9993 int *ix0,
int *iy0,
int *ix1,
int *iy1)
9996 if (!nk_tt_GetGlyphBox(font, glyph, &x0,&y0,&x1,&y1)) {
10004 if (ix0) *ix0 = nk_ifloorf((
float)x0 * scale_x + shift_x);
10005 if (iy0) *iy0 = nk_ifloorf((
float)-y1 * scale_y + shift_y);
10006 if (ix1) *ix1 = nk_iceilf ((
float)x1 * scale_x + shift_x);
10007 if (iy1) *iy1 = nk_iceilf ((
float)-y0 * scale_y + shift_y);
10012 nk_tt_GetGlyphBitmapBox(
const struct nk_tt_fontinfo *font,
int glyph,
10013 float scale_x,
float scale_y,
int *ix0,
int *iy0,
int *ix1,
int *iy1)
10015 nk_tt_GetGlyphBitmapBoxSubpixel(font, glyph, scale_x, scale_y,0.0f,0.0f, ix0, iy0, ix1, iy1);
10022 nk_tt__hheap_alloc(
struct nk_tt__hheap *hh, nk_size size)
10024 if (hh->first_free) {
10025 void *p = hh->first_free;
10026 hh->first_free = * (
void **) p;
10029 if (hh->num_remaining_in_head_chunk == 0) {
10030 int count = (size < 32 ? 2000 : size < 128 ? 800 : 100);
10031 struct nk_tt__hheap_chunk *c = (
struct nk_tt__hheap_chunk *)
10032 hh->alloc.alloc(hh->alloc.userdata, 0,
10033 sizeof(
struct nk_tt__hheap_chunk) + size * (nk_size)count);
10034 if (c == 0)
return 0;
10035 c->next = hh->head;
10037 hh->num_remaining_in_head_chunk = count;
10039 --hh->num_remaining_in_head_chunk;
10040 return (
char *) (hh->head) + size * (nk_size)hh->num_remaining_in_head_chunk;
10045 nk_tt__hheap_free(
struct nk_tt__hheap *hh,
void *p)
10047 *(
void **) p = hh->first_free;
10048 hh->first_free = p;
10052 nk_tt__hheap_cleanup(
struct nk_tt__hheap *hh)
10054 struct nk_tt__hheap_chunk *c = hh->head;
10056 struct nk_tt__hheap_chunk *n = c->next;
10057 hh->alloc.free(hh->alloc.userdata, c);
10063 nk_tt__new_active(
struct nk_tt__hheap *hh,
struct nk_tt__edge *e,
10064 int off_x,
float start_point)
10066 struct nk_tt__active_edge *z = (
struct nk_tt__active_edge *)
10067 nk_tt__hheap_alloc(hh,
sizeof(*z));
10068 float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0);
10072 z->fdy = (dxdy != 0) ? (1/dxdy): 0;
10073 z->fx = e->x0 + dxdy * (start_point - e->y0);
10074 z->fx -= (float)off_x;
10075 z->direction = e->invert ? 1.0f : -1.0f;
10083 nk_tt__handle_clipped_edge(
float *scanline,
int x,
struct nk_tt__active_edge *e,
10084 float x0,
float y0,
float x1,
float y1)
10086 if (y0 == y1)
return;
10087 NK_ASSERT(y0 < y1);
10088 NK_ASSERT(e->sy <= e->ey);
10089 if (y0 > e->ey)
return;
10090 if (y1 < e->sy)
return;
10092 x0 += (x1-x0) * (e->sy - y0) / (y1-y0);
10096 x1 += (x1-x0) * (e->ey - y1) / (y1-y0);
10100 if (x0 == x) NK_ASSERT(x1 <= x+1);
10101 else if (x0 == x+1) NK_ASSERT(x1 >= x);
10102 else if (x0 <= x) NK_ASSERT(x1 <= x);
10103 else if (x0 >= x+1) NK_ASSERT(x1 >= x+1);
10104 else NK_ASSERT(x1 >= x && x1 <= x+1);
10106 if (x0 <= x && x1 <= x)
10107 scanline[x] += e->direction * (y1-y0);
10108 else if (x0 >= x+1 && x1 >= x+1);
10110 NK_ASSERT(x0 >= x && x0 <= x+1 && x1 >= x && x1 <= x+1);
10112 scanline[x] += (float)e->direction * (
float)(y1-y0) * (1.0f-((x0-(
float)x)+(x1-(float)x))/2.0f);
10117 nk_tt__fill_active_edges_new(
float *scanline,
float *scanline_fill,
int len,
10118 struct nk_tt__active_edge *e,
float y_top)
10120 float y_bottom = y_top+1;
10125 NK_ASSERT(e->ey >= y_top);
10130 nk_tt__handle_clipped_edge(scanline,(
int) x0,e, x0,y_top, x0,y_bottom);
10131 nk_tt__handle_clipped_edge(scanline_fill-1,(
int) x0+1,e, x0,y_top, x0,y_bottom);
10133 nk_tt__handle_clipped_edge(scanline_fill-1,0,e, x0,y_top, x0,y_bottom);
10139 float xb = x0 + dx;
10140 float x_top, x_bottom;
10143 NK_ASSERT(e->sy <= y_bottom && e->ey >= y_top);
10148 if (e->sy > y_top) {
10149 x_top = x0 + dx * (e->sy - y_top);
10156 if (e->ey < y_bottom) {
10157 x_bottom = x0 + dx * (e->ey - y_top);
10164 if (x_top >= 0 && x_bottom >= 0 && x_top < len && x_bottom < len)
10167 if ((
int) x_top == (
int) x_bottom) {
10170 int x = (
int) x_top;
10172 NK_ASSERT(x >= 0 && x < len);
10173 scanline[x] += e->direction * (1.0f-(((float)x_top - (
float)x) + ((
float)x_bottom-(float)x))/2.0f) * (float)height;
10174 scanline_fill[x] += e->direction * (float)height;
10177 float y_crossing, step, sign, area;
10179 if (x_top > x_bottom)
10183 y0 = y_bottom - (y0 - y_top);
10184 y1 = y_bottom - (y1 - y_top);
10185 t = y0; y0 = y1; y1 = t;
10186 t = x_bottom; x_bottom = x_top; x_top = t;
10189 t = x0; x0 = xb; xb = t;
10193 x2 = (
int) x_bottom;
10195 y_crossing = ((float)x1+1 - (
float)x0) * (
float)dy + (float)y_top;
10197 sign = e->direction;
10199 area = sign * (y_crossing-y0);
10201 scanline[x1] += area * (1.0f-((float)((
float)x_top - (float)x1)+(float)(x1+1-x1))/2.0f);
10204 for (x = x1+1; x < x2; ++x) {
10205 scanline[x] += area + step/2;
10208 y_crossing += (float)dy * (
float)(x2 - (x1+1));
10210 scanline[x2] += area + sign * (1.0f-((float)(x2-x2)+((float)x_bottom-(
float)x2))/2.0f) * (y1-y_crossing);
10211 scanline_fill[x2] += sign * (y1-y0);
10221 for (x=0; x < len; ++x)
10238 float x1 = (float) (x);
10239 float x2 = (float) (x+1);
10241 float y3 = y_bottom;
10244 yb = ((float)x - x0) / dx + y_top;
10245 y2 = ((float)x+1 - x0) / dx + y_top;
10247 if (x0 < x1 && x3 > x2) {
10248 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x1,yb);
10249 nk_tt__handle_clipped_edge(scanline,x,e, x1,yb, x2,y2);
10250 nk_tt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3);
10251 }
else if (x3 < x1 && x0 > x2) {
10252 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x2,y2);
10253 nk_tt__handle_clipped_edge(scanline,x,e, x2,y2, x1,yb);
10254 nk_tt__handle_clipped_edge(scanline,x,e, x1,yb, x3,y3);
10255 }
else if (x0 < x1 && x3 > x1) {
10256 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x1,yb);
10257 nk_tt__handle_clipped_edge(scanline,x,e, x1,yb, x3,y3);
10258 }
else if (x3 < x1 && x0 > x1) {
10259 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x1,yb);
10260 nk_tt__handle_clipped_edge(scanline,x,e, x1,yb, x3,y3);
10261 }
else if (x0 < x2 && x3 > x2) {
10262 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x2,y2);
10263 nk_tt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3);
10264 }
else if (x3 < x2 && x0 > x2) {
10265 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x2,y2);
10266 nk_tt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3);
10268 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x3,y3);
10279 nk_tt__rasterize_sorted_edges(
struct nk_tt__bitmap *result,
struct nk_tt__edge *e,
10280 int n,
int vsubsample,
int off_x,
int off_y,
struct nk_allocator *alloc)
10282 struct nk_tt__hheap hh;
10283 struct nk_tt__active_edge *active = 0;
10285 float scanline_data[129], *scanline, *scanline2;
10291 if (result->w > 64)
10292 scanline = (
float *) alloc->
alloc(alloc->
userdata,0, (nk_size)(result->w*2+1) *
sizeof(
float));
10293 else scanline = scanline_data;
10295 scanline2 = scanline + result->w;
10297 e[n].y0 = (float) (off_y + result->h) + 1;
10299 while (j < result->h)
10302 float scan_y_top = (float)y + 0.0f;
10303 float scan_y_bottom = (float)y + 1.0f;
10304 struct nk_tt__active_edge **step = &active;
10306 NK_MEMSET(scanline , 0, (nk_size)result->w*
sizeof(scanline[0]));
10307 NK_MEMSET(scanline2, 0, (nk_size)(result->w+1)*
sizeof(scanline[0]));
10312 struct nk_tt__active_edge * z = *step;
10313 if (z->ey <= scan_y_top) {
10315 NK_ASSERT(z->direction);
10317 nk_tt__hheap_free(&hh, z);
10319 step = &((*step)->next);
10324 while (e->y0 <= scan_y_bottom) {
10325 if (e->y0 != e->y1) {
10326 struct nk_tt__active_edge *z = nk_tt__new_active(&hh, e, off_x, scan_y_top);
10328 NK_ASSERT(z->ey >= scan_y_top);
10339 nk_tt__fill_active_edges_new(scanline, scanline2+1, result->w, active, scan_y_top);
10343 for (i=0; i < result->w; ++i) {
10346 sum += scanline2[i];
10347 k = scanline[i] + sum;
10348 k = (float)
NK_ABS(k) * 255.0f + 0.5f;
10350 if (m > 255) m = 255;
10351 result->pixels[j*result->stride + i] = (
unsigned char) m;
10357 struct nk_tt__active_edge *z = *step;
10359 step = &((*step)->next);
10364 nk_tt__hheap_cleanup(&hh);
10365 if (scanline != scanline_data)
10369 #define NK_TT__COMPARE(a,b) ((a)->y0 < (b)->y0)
10371 nk_tt__sort_edges_ins_sort(
struct nk_tt__edge *p,
int n)
10374 for (i=1; i < n; ++i) {
10375 struct nk_tt__edge t = p[i], *a = &t;
10378 struct nk_tt__edge *b = &p[j-1];
10379 int c = NK_TT__COMPARE(a,b);
10390 nk_tt__sort_edges_quicksort(
struct nk_tt__edge *p,
int n)
10394 struct nk_tt__edge t;
10395 int c01,c12,c,
m,i,j;
10399 c01 = NK_TT__COMPARE(&p[0],&p[m]);
10400 c12 = NK_TT__COMPARE(&p[m],&p[n-1]);
10406 c = NK_TT__COMPARE(&p[0],&p[n-1]);
10409 z = (c == c12) ? 0 : n-1;
10428 if (!NK_TT__COMPARE(&p[i], &p[0]))
break;
10431 if (!NK_TT__COMPARE(&p[0], &p[j]))
break;
10447 nk_tt__sort_edges_quicksort(p,j);
10451 nk_tt__sort_edges_quicksort(p+i, n-i);
10458 nk_tt__sort_edges(
struct nk_tt__edge *p,
int n)
10460 nk_tt__sort_edges_quicksort(p, n);
10461 nk_tt__sort_edges_ins_sort(p, n);
10465 nk_tt__rasterize(
struct nk_tt__bitmap *result,
struct nk_tt__point *pts,
10466 int *wcount,
int windings,
float scale_x,
float scale_y,
10467 float shift_x,
float shift_y,
int off_x,
int off_y,
int invert,
10470 float y_scale_inv = invert ? -scale_y : scale_y;
10471 struct nk_tt__edge *e;
10473 int vsubsample = 1;
10478 for (i=0; i < windings; ++i)
10481 e = (
struct nk_tt__edge*)
10482 alloc->
alloc(alloc->
userdata, 0,(
sizeof(*e) * (nk_size)(n+1)));
10483 if (e == 0)
return;
10487 for (i=0; i < windings; ++i)
10489 struct nk_tt__point *p = pts +
m;
10492 for (k=0; k < wcount[i]; j=k++) {
10495 if (p[j].y == p[k].y)
10500 if (invert ? p[j].y > p[k].y : p[j].y < p[k].y) {
10504 e[n].x0 = p[a].x * scale_x + shift_x;
10505 e[n].y0 = (p[a].y * y_scale_inv + shift_y) * (
float)vsubsample;
10506 e[n].x1 = p[b].x * scale_x + shift_x;
10507 e[n].y1 = (p[b].y * y_scale_inv + shift_y) * (
float)vsubsample;
10514 nk_tt__sort_edges(e, n);
10516 nk_tt__rasterize_sorted_edges(result, e, n, vsubsample, off_x, off_y, alloc);
10521 nk_tt__add_point(
struct nk_tt__point *points,
int n,
float x,
float y)
10523 if (!points)
return;
10529 nk_tt__tesselate_curve(
struct nk_tt__point *points,
int *num_points,
10530 float x0,
float y0,
float x1,
float y1,
float x2,
float y2,
10531 float objspace_flatness_squared,
int n)
10536 float mx = (x0 + 2*x1 + x2)/4;
10537 float my = (y0 + 2*y1 + y2)/4;
10539 float dx = (x0+x2)/2 - mx;
10540 float dy = (y0+y2)/2 - my;
10545 if (dx*dx+dy*dy > objspace_flatness_squared) {
10546 nk_tt__tesselate_curve(points, num_points, x0,y0,
10547 (x0+x1)/2.0f,(y0+y1)/2.0f, mx,my, objspace_flatness_squared,n+1);
10548 nk_tt__tesselate_curve(points, num_points, mx,my,
10549 (x1+x2)/2.0f,(y1+y2)/2.0f, x2,y2, objspace_flatness_squared,n+1);
10551 nk_tt__add_point(points, *num_points,x2,y2);
10552 *num_points = *num_points+1;
10559 nk_tt_FlattenCurves(
struct nk_tt_vertex *vertices,
int num_verts,
10560 float objspace_flatness,
int **contour_lengths,
int *num_contours,
10563 struct nk_tt__point *points=0;
10565 float objspace_flatness_squared = objspace_flatness * objspace_flatness;
10572 for (i=0; i < num_verts; ++i)
10573 if (vertices[i].type == NK_TT_vmove) ++n;
10576 if (n == 0)
return 0;
10578 *contour_lengths = (
int *)
10579 alloc->
alloc(alloc->
userdata,0, (
sizeof(**contour_lengths) * (nk_size)n));
10580 if (*contour_lengths == 0) {
10586 for (pass=0; pass < 2; ++pass)
10590 points = (
struct nk_tt__point *)
10591 alloc->
alloc(alloc->
userdata,0, (nk_size)num_points *
sizeof(points[0]));
10592 if (points == 0)
goto error;
10597 for (i=0; i < num_verts; ++i)
10599 switch (vertices[i].type) {
10603 (*contour_lengths)[n] = num_points - start;
10605 start = num_points;
10607 x = vertices[i].x, y = vertices[i].y;
10608 nk_tt__add_point(points, num_points++, x,y);
10611 x = vertices[i].x, y = vertices[i].y;
10612 nk_tt__add_point(points, num_points++, x, y);
10615 nk_tt__tesselate_curve(points, &num_points, x,y,
10616 vertices[i].cx, vertices[i].cy,
10617 vertices[i].x, vertices[i].y,
10618 objspace_flatness_squared, 0);
10619 x = vertices[i].x, y = vertices[i].y;
10624 (*contour_lengths)[n] = num_points - start;
10631 *contour_lengths = 0;
10637 nk_tt_Rasterize(
struct nk_tt__bitmap *result,
float flatness_in_pixels,
10638 struct nk_tt_vertex *vertices,
int num_verts,
10639 float scale_x,
float scale_y,
float shift_x,
float shift_y,
10640 int x_off,
int y_off,
int invert,
struct nk_allocator *alloc)
10642 float scale = scale_x > scale_y ? scale_y : scale_x;
10643 int winding_count, *winding_lengths;
10644 struct nk_tt__point *windings = nk_tt_FlattenCurves(vertices, num_verts,
10645 flatness_in_pixels / scale, &winding_lengths, &winding_count, alloc);
10649 nk_tt__rasterize(result, windings, winding_lengths, winding_count,
10650 scale_x, scale_y, shift_x, shift_y, x_off, y_off, invert, alloc);
10657 nk_tt_MakeGlyphBitmapSubpixel(
const struct nk_tt_fontinfo *info,
unsigned char *output,
10658 int out_w,
int out_h,
int out_stride,
float scale_x,
float scale_y,
10659 float shift_x,
float shift_y,
int glyph,
struct nk_allocator *alloc)
10662 struct nk_tt_vertex *vertices;
10663 int num_verts = nk_tt_GetGlyphShape(info, alloc, glyph, &vertices);
10664 struct nk_tt__bitmap gbm;
10666 nk_tt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x,
10667 shift_y, &ix0,&iy0,0,0);
10671 gbm.stride = out_stride;
10673 if (gbm.w && gbm.h)
10674 nk_tt_Rasterize(&gbm, 0.35f, vertices, num_verts, scale_x, scale_y,
10675 shift_x, shift_y, ix0,iy0, 1, alloc);
10683 nk_tt_PackBegin(
struct nk_tt_pack_context *spc,
unsigned char *pixels,
10684 int pw,
int ph,
int stride_in_bytes,
int padding,
struct nk_allocator *alloc)
10686 int num_nodes = pw - padding;
10687 struct nk_rp_context *context = (
struct nk_rp_context *)
10689 struct nk_rp_node *nodes = (
struct nk_rp_node*)
10690 alloc->
alloc(alloc->
userdata,0, (
sizeof(*nodes ) * (nk_size)num_nodes));
10692 if (context == 0 || nodes == 0) {
10693 if (context != 0) alloc->
free(alloc->
userdata, context);
10700 spc->pixels = pixels;
10701 spc->pack_info = context;
10702 spc->nodes = nodes;
10703 spc->padding = padding;
10704 spc->stride_in_bytes = (stride_in_bytes != 0) ? stride_in_bytes : pw;
10705 spc->h_oversample = 1;
10706 spc->v_oversample = 1;
10708 nk_rp_init_target(context, pw-padding, ph-padding, nodes, num_nodes);
10710 NK_MEMSET(pixels, 0, (nk_size)(pw*ph));
10715 nk_tt_PackEnd(
struct nk_tt_pack_context *spc,
struct nk_allocator *alloc)
10722 nk_tt_PackSetOversampling(
struct nk_tt_pack_context *spc,
10723 unsigned int h_oversample,
unsigned int v_oversample)
10725 NK_ASSERT(h_oversample <= NK_TT_MAX_OVERSAMPLE);
10726 NK_ASSERT(v_oversample <= NK_TT_MAX_OVERSAMPLE);
10727 if (h_oversample <= NK_TT_MAX_OVERSAMPLE)
10728 spc->h_oversample = h_oversample;
10729 if (v_oversample <= NK_TT_MAX_OVERSAMPLE)
10730 spc->v_oversample = v_oversample;
10734 nk_tt__h_prefilter(
unsigned char *pixels,
int w,
int h,
int stride_in_bytes,
10737 unsigned char buffer[NK_TT_MAX_OVERSAMPLE];
10738 int safe_w = w - kernel_width;
10741 for (j=0; j < h; ++j)
10744 unsigned int total;
10745 NK_MEMSET(buffer, 0, (nk_size)kernel_width);
10750 switch (kernel_width) {
10752 for (i=0; i <= safe_w; ++i) {
10753 total += (
unsigned int)(pixels[i] - buffer[i & NK_TT__OVER_MASK]);
10754 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i];
10755 pixels[i] = (
unsigned char) (total / 2);
10759 for (i=0; i <= safe_w; ++i) {
10760 total += (
unsigned int)(pixels[i] - buffer[i & NK_TT__OVER_MASK]);
10761 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i];
10762 pixels[i] = (
unsigned char) (total / 3);
10766 for (i=0; i <= safe_w; ++i) {
10767 total += (
unsigned int)pixels[i] - buffer[i & NK_TT__OVER_MASK];
10768 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i];
10769 pixels[i] = (
unsigned char) (total / 4);
10773 for (i=0; i <= safe_w; ++i) {
10774 total += (
unsigned int)(pixels[i] - buffer[i & NK_TT__OVER_MASK]);
10775 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i];
10776 pixels[i] = (
unsigned char) (total / 5);
10780 for (i=0; i <= safe_w; ++i) {
10781 total += (
unsigned int)(pixels[i] - buffer[i & NK_TT__OVER_MASK]);
10782 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i];
10783 pixels[i] = (
unsigned char) (total / (
unsigned int)kernel_width);
10788 for (; i < w; ++i) {
10789 NK_ASSERT(pixels[i] == 0);
10790 total -= (
unsigned int)(buffer[i & NK_TT__OVER_MASK]);
10791 pixels[i] = (
unsigned char) (total / (
unsigned int)kernel_width);
10793 pixels += stride_in_bytes;
10798 nk_tt__v_prefilter(
unsigned char *pixels,
int w,
int h,
int stride_in_bytes,
10801 unsigned char buffer[NK_TT_MAX_OVERSAMPLE];
10802 int safe_h = h - kernel_width;
10805 for (j=0; j < w; ++j)
10808 unsigned int total;
10809 NK_MEMSET(buffer, 0, (nk_size)kernel_width);
10814 switch (kernel_width) {
10816 for (i=0; i <= safe_h; ++i) {
10817 total += (
unsigned int)(pixels[i*stride_in_bytes] - buffer[i & NK_TT__OVER_MASK]);
10818 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i*stride_in_bytes];
10819 pixels[i*stride_in_bytes] = (
unsigned char) (total / 2);
10823 for (i=0; i <= safe_h; ++i) {
10824 total += (
unsigned int)(pixels[i*stride_in_bytes] - buffer[i & NK_TT__OVER_MASK]);
10825 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i*stride_in_bytes];
10826 pixels[i*stride_in_bytes] = (
unsigned char) (total / 3);
10830 for (i=0; i <= safe_h; ++i) {
10831 total += (
unsigned int)(pixels[i*stride_in_bytes] - buffer[i & NK_TT__OVER_MASK]);
10832 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i*stride_in_bytes];
10833 pixels[i*stride_in_bytes] = (
unsigned char) (total / 4);
10837 for (i=0; i <= safe_h; ++i) {
10838 total += (
unsigned int)(pixels[i*stride_in_bytes] - buffer[i & NK_TT__OVER_MASK]);
10839 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i*stride_in_bytes];
10840 pixels[i*stride_in_bytes] = (
unsigned char) (total / 5);
10844 for (i=0; i <= safe_h; ++i) {
10845 total += (
unsigned int)(pixels[i*stride_in_bytes] - buffer[i & NK_TT__OVER_MASK]);
10846 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i*stride_in_bytes];
10847 pixels[i*stride_in_bytes] = (
unsigned char) (total / (
unsigned int)kernel_width);
10852 for (; i < h; ++i) {
10853 NK_ASSERT(pixels[i*stride_in_bytes] == 0);
10854 total -= (
unsigned int)(buffer[i & NK_TT__OVER_MASK]);
10855 pixels[i*stride_in_bytes] = (
unsigned char) (total / (
unsigned int)kernel_width);
10862 nk_tt__oversample_shift(
int oversample)
10871 return (
float)-(oversample - 1) / (2.0f * (
float)oversample);
10876 nk_tt_PackFontRangesGatherRects(
struct nk_tt_pack_context *spc,
10877 struct nk_tt_fontinfo *info,
struct nk_tt_pack_range *ranges,
10878 int num_ranges,
struct nk_rp_rect *rects)
10883 for (i=0; i < num_ranges; ++i) {
10884 float fh = ranges[i].font_size;
10885 float scale = (fh > 0) ? nk_tt_ScaleForPixelHeight(info, fh):
10886 nk_tt_ScaleForMappingEmToPixels(info, -fh);
10887 ranges[i].h_oversample = (
unsigned char) spc->h_oversample;
10888 ranges[i].v_oversample = (
unsigned char) spc->v_oversample;
10889 for (j=0; j < ranges[i].num_chars; ++j) {
10891 int codepoint = ranges[i].first_unicode_codepoint_in_range ?
10892 ranges[i].first_unicode_codepoint_in_range + j :
10893 ranges[i].array_of_unicode_codepoints[j];
10895 int glyph = nk_tt_FindGlyphIndex(info, codepoint);
10896 nk_tt_GetGlyphBitmapBoxSubpixel(info,glyph, scale * (
float)spc->h_oversample,
10897 scale * (
float)spc->v_oversample, 0,0, &x0,&y0,&x1,&y1);
10898 rects[k].w = (nk_rp_coord) (x1-x0 + spc->padding + (
int)spc->h_oversample-1);
10899 rects[k].h = (nk_rp_coord) (y1-y0 + spc->padding + (
int)spc->v_oversample-1);
10907 nk_tt_PackFontRangesRenderIntoRects(
struct nk_tt_pack_context *spc,
10908 struct nk_tt_fontinfo *info,
struct nk_tt_pack_range *ranges,
10909 int num_ranges,
struct nk_rp_rect *rects,
struct nk_allocator *alloc)
10911 int i,j,k, return_value = 1;
10913 int old_h_over = (
int)spc->h_oversample;
10914 int old_v_over = (
int)spc->v_oversample;
10918 for (i=0; i < num_ranges; ++i)
10920 float fh = ranges[i].font_size;
10921 float recip_h,recip_v,sub_x,sub_y;
10922 float scale = fh > 0 ? nk_tt_ScaleForPixelHeight(info, fh):
10923 nk_tt_ScaleForMappingEmToPixels(info, -fh);
10925 spc->h_oversample = ranges[i].h_oversample;
10926 spc->v_oversample = ranges[i].v_oversample;
10928 recip_h = 1.0f / (float)spc->h_oversample;
10929 recip_v = 1.0f / (
float)spc->v_oversample;
10931 sub_x = nk_tt__oversample_shift((
int)spc->h_oversample);
10932 sub_y = nk_tt__oversample_shift((
int)spc->v_oversample);
10934 for (j=0; j < ranges[i].num_chars; ++j)
10936 struct nk_rp_rect *r = &rects[k];
10939 struct nk_tt_packedchar *bc = &ranges[i].chardata_for_range[j];
10940 int advance, lsb, x0,y0,x1,y1;
10941 int codepoint = ranges[i].first_unicode_codepoint_in_range ?
10942 ranges[i].first_unicode_codepoint_in_range + j :
10943 ranges[i].array_of_unicode_codepoints[j];
10944 int glyph = nk_tt_FindGlyphIndex(info, codepoint);
10945 nk_rp_coord pad = (nk_rp_coord) spc->padding;
10948 r->x = (nk_rp_coord)((
int)r->x + (
int)pad);
10949 r->y = (nk_rp_coord)((
int)r->y + (
int)pad);
10950 r->w = (nk_rp_coord)((
int)r->w - (
int)pad);
10951 r->h = (nk_rp_coord)((
int)r->h - (
int)pad);
10953 nk_tt_GetGlyphHMetrics(info, glyph, &advance, &lsb);
10954 nk_tt_GetGlyphBitmapBox(info, glyph, scale * (
float)spc->h_oversample,
10955 (scale * (
float)spc->v_oversample), &x0,&y0,&x1,&y1);
10956 nk_tt_MakeGlyphBitmapSubpixel(info, spc->pixels + r->x + r->y*spc->stride_in_bytes,
10957 (
int)(r->w - spc->h_oversample+1), (
int)(r->h - spc->v_oversample+1),
10958 spc->stride_in_bytes, scale * (
float)spc->h_oversample,
10959 scale * (
float)spc->v_oversample, 0,0, glyph, alloc);
10961 if (spc->h_oversample > 1)
10962 nk_tt__h_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes,
10963 r->w, r->h, spc->stride_in_bytes, (
int)spc->h_oversample);
10965 if (spc->v_oversample > 1)
10966 nk_tt__v_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes,
10967 r->w, r->h, spc->stride_in_bytes, (
int)spc->v_oversample);
10970 bc->y0 = (nk_ushort) r->y;
10973 bc->xadvance = scale * (float)advance;
10974 bc->xoff = (float) x0 * recip_h + sub_x;
10975 bc->yoff = (float) y0 * recip_v + sub_y;
10976 bc->xoff2 = ((float)x0 + r->w) * recip_h + sub_x;
10977 bc->yoff2 = ((float)y0 + r->h) * recip_v + sub_y;
10985 spc->h_oversample = (
unsigned int)old_h_over;
10986 spc->v_oversample = (
unsigned int)old_v_over;
10987 return return_value;
10991 nk_tt_GetPackedQuad(
struct nk_tt_packedchar *chardata,
int pw,
int ph,
10992 int char_index,
float *xpos,
float *ypos,
struct nk_tt_aligned_quad *q,
10993 int align_to_integer)
10995 float ipw = 1.0f / (float)pw, iph = 1.0f / (
float)ph;
10996 struct nk_tt_packedchar *b = (
struct nk_tt_packedchar*)(chardata + char_index);
10997 if (align_to_integer) {
10998 int tx = nk_ifloorf((*xpos + b->xoff) + 0.5f);
10999 int ty = nk_ifloorf((*ypos + b->yoff) + 0.5f);
11001 float x = (float)tx;
11002 float y = (float)ty;
11006 q->x1 = x + b->xoff2 - b->xoff;
11007 q->y1 = y + b->yoff2 - b->yoff;
11009 q->x0 = *xpos + b->xoff;
11010 q->y0 = *ypos + b->yoff;
11011 q->x1 = *xpos + b->xoff2;
11012 q->y1 = *ypos + b->yoff2;
11014 q->s0 = b->x0 * ipw;
11015 q->t0 = b->y0 * iph;
11016 q->s1 = b->x1 * ipw;
11017 q->t1 = b->y1 * iph;
11018 *xpos += b->xadvance;
11026 struct nk_font_bake_data {
11027 struct nk_tt_fontinfo info;
11028 struct nk_rp_rect *rects;
11029 struct nk_tt_pack_range *ranges;
11030 nk_rune range_count;
11033 struct nk_font_baker {
11035 struct nk_tt_pack_context spc;
11036 struct nk_font_bake_data *build;
11037 struct nk_tt_packedchar *packed_chars;
11038 struct nk_rp_rect *rects;
11039 struct nk_tt_pack_range *ranges;
11049 nk_range_count(
const nk_rune *range)
11051 const nk_rune *iter = range;
11053 if (!range)
return 0;
11054 while (*(iter++) != 0);
11055 return (iter == range) ? 0 : (
int)((iter - range)/2);
11059 nk_range_glyph_count(
const nk_rune *range,
int count)
11062 int total_glyphs = 0;
11063 for (i = 0; i < count; ++i) {
11065 nk_rune f = range[(i*2)+0];
11066 nk_rune t = range[(i*2)+1];
11068 diff = (
int)((t - f) + 1);
11069 total_glyphs += diff;
11071 return total_glyphs;
11075 nk_font_default_glyph_ranges(
void)
11077 NK_STORAGE const nk_rune ranges[] = {0x0020, 0x00FF, 0};
11082 nk_font_chinese_glyph_ranges(
void)
11096 nk_font_cyrillic_glyph_ranges(
void)
11109 nk_font_korean_glyph_ranges(
void)
11121 nk_font_baker_memory(nk_size *temp,
int *glyph_count,
11122 struct nk_font_config *config_list,
int count)
11124 int range_count = 0;
11125 int total_range_count = 0;
11126 struct nk_font_config *iter;
11128 NK_ASSERT(config_list);
11129 NK_ASSERT(glyph_count);
11130 if (!config_list) {
11137 if (!config_list->range)
11138 config_list->range = nk_font_default_glyph_ranges();
11139 for (iter = config_list; iter; iter = iter->next) {
11140 range_count = nk_range_count(iter->range);
11141 total_range_count += range_count;
11142 *glyph_count += nk_range_glyph_count(iter->range, range_count);
11145 *temp = (
nk_size)*glyph_count *
sizeof(
struct nk_rp_rect);
11146 *temp += (
nk_size)total_range_count *
sizeof(
struct nk_tt_pack_range);
11147 *temp += (
nk_size)*glyph_count *
sizeof(
struct nk_tt_packedchar);
11148 *temp += (
nk_size)count *
sizeof(
struct nk_font_bake_data);
11149 *temp +=
sizeof(
struct nk_font_baker);
11150 *temp += nk_rect_align + nk_range_align + nk_char_align;
11151 *temp += nk_build_align + nk_baker_align;
11155 nk_font_baker(
void *memory,
int glyph_count,
int count,
struct nk_allocator *alloc)
11157 struct nk_font_baker *baker;
11158 if (!memory)
return 0;
11160 baker = (
struct nk_font_baker*)
NK_ALIGN_PTR(memory, nk_baker_align);
11161 baker->build = (
struct nk_font_bake_data*)
NK_ALIGN_PTR((baker + 1), nk_build_align);
11162 baker->packed_chars = (
struct nk_tt_packedchar*)
NK_ALIGN_PTR((baker->build + count), nk_char_align);
11163 baker->rects = (
struct nk_rp_rect*)
NK_ALIGN_PTR((baker->packed_chars + glyph_count), nk_rect_align);
11164 baker->ranges = (
struct nk_tt_pack_range*)
NK_ALIGN_PTR((baker->rects + glyph_count), nk_range_align);
11165 baker->alloc = *alloc;
11170 nk_font_bake_pack(
struct nk_font_baker *baker,
11171 nk_size *image_memory,
int *width,
int *height,
struct nk_recti *custom,
11172 const struct nk_font_config *config_list,
int count,
11175 NK_STORAGE const nk_size max_height = 1024 * 32;
11176 const struct nk_font_config *config_iter;
11177 int total_glyph_count = 0;
11178 int total_range_count = 0;
11179 int range_count = 0;
11182 NK_ASSERT(image_memory);
11185 NK_ASSERT(config_list);
11189 if (!image_memory || !width || !height || !config_list || !count)
return nk_false;
11190 for (config_iter = config_list; config_iter; config_iter = config_iter->next) {
11191 range_count = nk_range_count(config_iter->range);
11192 total_range_count += range_count;
11193 total_glyph_count += nk_range_glyph_count(config_iter->range, range_count);
11197 for (config_iter = config_list; config_iter; config_iter = config_iter->next) {
11198 const struct nk_font_config *cfg = config_iter;
11199 if (!nk_tt_InitFont(&baker->build[i++].info, (
const unsigned char*)cfg->ttf_blob, 0))
11204 *width = (total_glyph_count > 1000) ? 1024 : 512;
11205 nk_tt_PackBegin(&baker->spc, 0, (
int)*width, (
int)max_height, 0, 1, alloc);
11214 struct nk_rp_rect custom_space;
11215 nk_zero(&custom_space,
sizeof(custom_space));
11216 custom_space.w = (nk_rp_coord)((custom->
w * 2) + 1);
11217 custom_space.h = (nk_rp_coord)(custom->
h + 1);
11219 nk_tt_PackSetOversampling(&baker->spc, 1, 1);
11220 nk_rp_pack_rects((
struct nk_rp_context*)baker->spc.pack_info, &custom_space, 1);
11221 *height =
NK_MAX(*height, (
int)(custom_space.y + custom_space.h));
11223 custom->
x = (short)custom_space.x;
11224 custom->
y = (
short)custom_space.y;
11225 custom->
w = (short)custom_space.w;
11226 custom->
h = (
short)custom_space.h;
11230 for (input_i = 0, config_iter = config_list; input_i < count && config_iter;
11231 input_i++, config_iter = config_iter->next)
11235 const nk_rune *in_range;
11236 const struct nk_font_config *cfg = config_iter;
11237 struct nk_font_bake_data *tmp = &baker->build[input_i];
11240 glyph_count = 0; range_count = 0;
11241 for (in_range = cfg->range; in_range[0] && in_range[1]; in_range += 2) {
11242 glyph_count += (
int)(in_range[1] - in_range[0]) + 1;
11247 tmp->ranges = baker->ranges + range_n;
11248 tmp->range_count = (
nk_rune)range_count;
11249 range_n += range_count;
11250 for (i = 0; i < range_count; ++i) {
11251 in_range = &cfg->range[i * 2];
11252 tmp->ranges[i].font_size = cfg->size;
11253 tmp->ranges[i].first_unicode_codepoint_in_range = (
int)in_range[0];
11254 tmp->ranges[i].num_chars = (
int)(in_range[1]- in_range[0]) + 1;
11255 tmp->ranges[i].chardata_for_range = baker->packed_chars + char_n;
11256 char_n += tmp->ranges[i].num_chars;
11260 tmp->rects = baker->rects + rect_n;
11261 rect_n += glyph_count;
11262 nk_tt_PackSetOversampling(&baker->spc, cfg->oversample_h, cfg->oversample_v);
11263 n = nk_tt_PackFontRangesGatherRects(&baker->spc, &tmp->info,
11264 tmp->ranges, (
int)tmp->range_count, tmp->rects);
11265 nk_rp_pack_rects((
struct nk_rp_context*)baker->spc.pack_info, tmp->rects, (
int)n);
11268 for (i = 0; i < n; ++i) {
11269 if (tmp->rects[i].was_packed)
11270 *height =
NK_MAX(*height, tmp->rects[i].y + tmp->rects[i].h);
11273 NK_ASSERT(rect_n == total_glyph_count);
11274 NK_ASSERT(char_n == total_glyph_count);
11275 NK_ASSERT(range_n == total_range_count);
11277 *height = (
int)nk_round_up_pow2((nk_uint)*height);
11283 nk_font_bake(
struct nk_font_baker *baker,
void *image_memory,
int width,
int height,
11284 struct nk_font_glyph *glyphs,
int glyphs_count,
11285 const struct nk_font_config *config_list,
int font_count)
11288 nk_rune glyph_n = 0;
11289 const struct nk_font_config *config_iter;
11291 NK_ASSERT(image_memory);
11294 NK_ASSERT(config_list);
11296 NK_ASSERT(font_count);
11297 NK_ASSERT(glyphs_count);
11298 if (!image_memory || !width || !height || !config_list ||
11299 !font_count || !glyphs || !glyphs_count)
11303 nk_zero(image_memory, (nk_size)((nk_size)width * (nk_size)height));
11304 baker->spc.pixels = (
unsigned char*)image_memory;
11305 baker->spc.height = (
int)height;
11306 for (input_i = 0, config_iter = config_list; input_i < font_count && config_iter;
11307 ++input_i, config_iter = config_iter->next)
11309 const struct nk_font_config *cfg = config_iter;
11310 struct nk_font_bake_data *tmp = &baker->build[input_i];
11311 nk_tt_PackSetOversampling(&baker->spc, cfg->oversample_h, cfg->oversample_v);
11312 nk_tt_PackFontRangesRenderIntoRects(&baker->spc, &tmp->info, tmp->ranges,
11313 (
int)tmp->range_count, tmp->rects, &baker->alloc);
11315 nk_tt_PackEnd(&baker->spc, &baker->alloc);
11318 for (input_i = 0, config_iter = config_list; input_i < font_count && config_iter;
11319 ++input_i, config_iter = config_iter->next)
11323 nk_rune glyph_count = 0;
11324 const struct nk_font_config *cfg = config_iter;
11325 struct nk_font_bake_data *tmp = &baker->build[input_i];
11326 struct nk_baked_font *dst_font = cfg->font;
11328 float font_scale = nk_tt_ScaleForPixelHeight(&tmp->info, cfg->size);
11329 int unscaled_ascent, unscaled_descent, unscaled_line_gap;
11330 nk_tt_GetFontVMetrics(&tmp->info, &unscaled_ascent, &unscaled_descent,
11331 &unscaled_line_gap);
11334 if (!cfg->merge_mode) {
11335 dst_font->ranges = cfg->range;
11336 dst_font->height = cfg->size;
11337 dst_font->ascent = ((float)unscaled_ascent * font_scale);
11338 dst_font->descent = ((float)unscaled_descent * font_scale);
11339 dst_font->glyph_offset = glyph_n;
11343 for (i = 0; i < tmp->range_count; ++i)
11345 struct nk_tt_pack_range *range = &tmp->ranges[i];
11346 for (char_idx = 0; char_idx < range->num_chars; char_idx++)
11348 nk_rune codepoint = 0;
11349 float dummy_x = 0, dummy_y = 0;
11350 struct nk_tt_aligned_quad q;
11351 struct nk_font_glyph *glyph;
11354 const struct nk_tt_packedchar *pc = &range->chardata_for_range[char_idx];
11355 if (!pc->x0 && !pc->x1 && !pc->y0 && !pc->y1)
continue;
11356 codepoint = (
nk_rune)(range->first_unicode_codepoint_in_range + char_idx);
11357 nk_tt_GetPackedQuad(range->chardata_for_range, (
int)width,
11358 (
int)height, char_idx, &dummy_x, &dummy_y, &q, 0);
11361 glyph = &glyphs[dst_font->glyph_offset + (
unsigned int)glyph_count];
11362 glyph->codepoint = codepoint;
11363 glyph->x0 = q.x0; glyph->y0 = q.y0;
11364 glyph->x1 = q.x1; glyph->y1 = q.y1;
11365 glyph->y0 += (dst_font->ascent + 0.5f);
11366 glyph->y1 += (dst_font->ascent + 0.5f);
11367 glyph->w = glyph->x1 - glyph->x0 + 0.5f;
11368 glyph->h = glyph->y1 - glyph->y0;
11370 if (cfg->coord_type == NK_COORD_PIXEL) {
11371 glyph->u0 = q.s0 * (float)width;
11372 glyph->v0 = q.t0 * (float)height;
11373 glyph->u1 = q.s1 * (float)width;
11374 glyph->v1 = q.t1 * (float)height;
11381 glyph->xadvance = (pc->xadvance + cfg->spacing.x);
11382 if (cfg->pixel_snap)
11383 glyph->xadvance = (float)(
int)(glyph->xadvance + 0.5f);
11387 dst_font->glyph_count = glyph_count;
11388 glyph_n += dst_font->glyph_count;
11393 nk_font_bake_custom_data(
void *img_memory,
int img_width,
int img_height,
11394 struct nk_recti img_dst,
const char *texture_data_mask,
int tex_width,
11395 int tex_height,
char white,
char black)
11402 NK_ASSERT(img_memory);
11403 NK_ASSERT(img_width);
11404 NK_ASSERT(img_height);
11405 NK_ASSERT(texture_data_mask);
11407 if (!img_memory || !img_width || !img_height || !texture_data_mask)
11410 pixels = (nk_byte*)img_memory;
11411 for (y = 0, n = 0; y < tex_height; ++y) {
11412 for (x = 0; x < tex_width; ++x, ++n) {
11413 const int off0 = ((img_dst.
x + x) + (img_dst.
y + y) * img_width);
11414 const int off1 = off0 + 1 + tex_width;
11415 pixels[off0] = (texture_data_mask[n] == white) ? 0xFF : 0x00;
11416 pixels[off1] = (texture_data_mask[n] == black) ? 0xFF : 0x00;
11422 nk_font_bake_convert(
void *out_memory,
int img_width,
int img_height,
11423 const void *in_memory)
11427 const nk_byte *src;
11429 NK_ASSERT(out_memory);
11430 NK_ASSERT(in_memory);
11431 NK_ASSERT(img_width);
11432 NK_ASSERT(img_height);
11433 if (!out_memory || !in_memory || !img_height || !img_width)
return;
11435 dst = (nk_rune*)out_memory;
11436 src = (
const nk_byte*)in_memory;
11437 for (n = (
int)(img_width * img_height); n > 0; n--)
11438 *dst++ = ((nk_rune)(*src++) << 24) | 0x00FFFFFF;
11447 nk_font_text_width(nk_handle handle,
float height,
const char *text,
int len)
11451 float text_width = 0;
11455 struct nk_font *font = (
struct nk_font*)handle.
ptr;
11457 NK_ASSERT(font->glyphs);
11458 if (!font || !text || !len)
11461 scale = height/font->info.height;
11462 glyph_len = text_len =
nk_utf_decode(text, &unicode, (
int)len);
11463 if (!glyph_len)
return 0;
11464 while (text_len <= (
int)len && glyph_len) {
11465 const struct nk_font_glyph *g;
11469 g = nk_font_find_glyph(font, unicode);
11470 text_width += g->xadvance * scale;
11473 glyph_len =
nk_utf_decode(text + text_len, &unicode, (
int)len - text_len);
11474 text_len += glyph_len;
11479 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
11481 nk_font_query_font_glyph(nk_handle handle,
float height,
11482 struct nk_user_font_glyph *glyph, nk_rune codepoint, nk_rune next_codepoint)
11485 const struct nk_font_glyph *g;
11486 struct nk_font *font;
11491 font = (
struct nk_font*)handle.
ptr;
11493 NK_ASSERT(font->glyphs);
11494 if (!font || !glyph)
11497 scale = height/font->info.height;
11498 g = nk_font_find_glyph(font, codepoint);
11499 glyph->width = (g->x1 - g->x0) * scale;
11500 glyph->height = (g->y1 - g->y0) * scale;
11501 glyph->offset =
nk_vec2(g->x0 * scale, g->y0 * scale);
11502 glyph->xadvance = (g->xadvance * scale);
11503 glyph->uv[0] =
nk_vec2(g->u0, g->v0);
11504 glyph->uv[1] =
nk_vec2(g->u1, g->v1);
11508 NK_API const struct nk_font_glyph*
11509 nk_font_find_glyph(
struct nk_font *font, nk_rune unicode)
11513 int total_glyphs = 0;
11514 const struct nk_font_glyph *glyph = 0;
11517 NK_ASSERT(font->glyphs);
11518 NK_ASSERT(font->info.ranges);
11519 if (!font || !font->glyphs)
return 0;
11521 glyph = font->fallback;
11522 count = nk_range_count(font->info.ranges);
11523 for (i = 0; i < count; ++i) {
11525 nk_rune f = font->info.ranges[(i*2)+0];
11526 nk_rune t = font->info.ranges[(i*2)+1];
11527 diff = (
int)((t - f) + 1);
11528 if (unicode >= f && unicode <= t)
11529 return &font->glyphs[((
nk_rune)total_glyphs + (unicode - f))];
11530 total_glyphs += diff;
11536 nk_font_init(
struct nk_font *font,
float pixel_height,
11537 nk_rune fallback_codepoint,
struct nk_font_glyph *glyphs,
11538 const struct nk_baked_font *baked_font, nk_handle atlas)
11540 struct nk_baked_font baked;
11543 NK_ASSERT(baked_font);
11544 if (!font || !glyphs || !baked_font)
11547 baked = *baked_font;
11548 font->info = baked;
11549 font->scale = (float)pixel_height / (
float)font->info.height;
11550 font->glyphs = &glyphs[baked_font->glyph_offset];
11551 font->texture = atlas;
11552 font->fallback_codepoint = fallback_codepoint;
11553 font->fallback = nk_font_find_glyph(font, fallback_codepoint);
11555 font->handle.height = font->info.height * font->scale;
11556 font->handle.width = nk_font_text_width;
11557 font->handle.userdata.ptr = font;
11558 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
11559 font->handle.query = nk_font_query_font_glyph;
11560 font->handle.texture = font->texture;
11573 #ifdef NK_INCLUDE_DEFAULT_FONT
11576 #pragma clang diagnostic push
11578 #pragma clang diagnostic ignored "-Woverlength-strings"
11579 #elif defined(__GNUC__) || defined(__GNUG__)
11580 #pragma GCC diagnostic push
11581 #pragma GCC diagnostic ignored "-Woverlength-strings"
11584 NK_GLOBAL const char nk_proggy_clean_ttf_compressed_data_base85[11980+1] =
11585 "7])#######hV0qs'/###[),##/l:$#Q6>##5[n42>c-TH`->>#/e>11NNV=Bv(*:.F?uu#(gRU.o0XGH`$vhLG1hxt9?W`#,5LsCp#-i>.r$<$6pD>Lb';9Crc6tgXmKVeU2cD4Eo3R/"
11586 "2*>]b(MC;$jPfY.;h^`IWM9<Lh2TlS+f-s$o6Q<BWH`YiU.xfLq$N;$0iR/GX:U(jcW2p/W*q?-qmnUCI;jHSAiFWM.R*kU@C=GH?a9wp8f$e.-4^Qg1)Q-GL(lf(r/7GrRgwV%MS=C#"
11587 "`8ND>Qo#t'X#(v#Y9w0#1D$CIf;W'#pWUPXOuxXuU(H9M(1<q-UE31#^-V'8IRUo7Qf./L>=Ke$$'5F%)]0^#0X@U.a<r:QLtFsLcL6##lOj)#.Y5<-R&KgLwqJfLgN&;Q?gI^#DY2uL"
11588 "i@^rMl9t=cWq6##weg>$FBjVQTSDgEKnIS7EM9>ZY9w0#L;>>#Mx&4Mvt//L[MkA#W@lK.N'[0#7RL_&#w+F%HtG9M#XL`N&.,GM4Pg;-<nLENhvx>-VsM.M0rJfLH2eTM`*oJMHRC`N"
11589 "kfimM2J,W-jXS:)r0wK#@Fge$U>`w'N7G#$#fB#$E^$#:9:hk+eOe--6x)F7*E%?76%^GMHePW-Z5l'&GiF#$956:rS?dA#fiK:)Yr+`�j@'DbG&#^$PG.Ll+DNa<XCMKEV*N)LN/N"
11590 "*b=%Q6pia-Xg8I$<MR&,VdJe$<(7G;Ckl'&hF;;$<_=X(b.RS%%)###MPBuuE1V:v&cXm#(&cV]`k9OhLMbn%s$G2,B$BfD3X*sp5#l,$R#]x_X1xKX%b5U*[r5iMfUo9U`N99hG)"
11591 "tm+/Us9pG)XPu`<0s-)WTt(gCRxIg(%6sfh=ktMKn3j)<6<b5Sk_/0(^]AaN#(p/L>&VZ>1i%h1S9u5o@YaaW$e+b<TWFn/Z:Oh(Cx2$lNEoN^e)#CFY@@I;BOQ*sRwZtZxRcU7uW6CX"
11592 "ow0i(?$Q[cjOd[P4d)]>ROPOpxTO7Stwi1::iB1q)C_=dV26J;2,]7op$]uQr@_V7$q^%lQwtuHY]=DX,n3L#0PHDO4f9>dC@O>HBuKPpP*E,N+b3L#lpR/MrTEH.IAQk.a>D[.e;mc."
11593 "x]Ip.PH^'/aqUO/$1WxLoW0[iLA<QT;5HKD+@qQ'NQ(3_PLhE48R.qAPSwQ0/WK?Z,[x?-J;jQTWA0X@KJ(_Y8N-:/M74:/-ZpKrUss?d#dZq]DAbkU*JqkL+nwX@@47`5>w=4h(9.`G"
11594 "CRUxHPeR`5Mjol(dUWxZa(>STrPkrJiWx`5U7F#.g*jrohGg`cg:lSTvEY/EV_7H4Q9[Z%cnv;JQYZ5q.l7Zeas:HOIZOB?G<Nald$qs]@]L<J7bR*>gv:[7MI2k).'2($5FNP&EQ(,)"
11595 "U]W]+fh18.vsai00);D3@4ku5P?DP8aJt+;qUM]=+b'8@;mViBKx0DE[-auGl8:PJ&Dj+M6OC]O^((##]`0i)drT;-7X`=-H3[igUnPG-NZlo.#k@h#=Ork$m>a>$-?Tm$UV(?#P6YY#"
11596 "'/###xe7q.73rI3*pP/$1>s9)W,JrM7SN]'/4C#v$U`0#V.[0>xQsH$fEmPMgY2u7Kh(G%siIfLSoS+MK2eTM$=5,M8p`A.;_R%#u[K#$x4AG8.kK/HSB==-'Ie/QTtG?-.*^N-4B/ZM"
11597 "_3YlQC7(p7q)&](`6_c)$/*JL(L-^(]$wIM`dPtOdGA,U3:w2M-0<q-]L_?^)1vw'.,MRsqVr.L;aN&#/EgJ)PBc[-f>+WomX2u7lqM2iEumMTcsF?-aT=Z-97UEnXglEn1K-bnEO`gu"
11598 "Ft(c%=;Am_Qs@jLooI&NX;]0#j4#F14;gl8-GQpgwhrq8'=l_f-b49'UOqkLu7-##oDY2L(te+Mch&gLYtJ,MEtJfLh'x'M=$CS-ZZ%P]8bZ>#S?YY#%Q&q'3^Fw&?D)UDNrocM3A76/"
11599 "/oL?#h7gl85[qW/NDOk%16ij;+:1a'iNIdb-ou8.P*w,v5#EI$TWS>Pot-R*H'-SEpA:g)f+O$%%`kA#G=8RMmG1&O`>to8bC]T&$,n.LoO>29sp3dt-52U%VM#q7'DHpg+#Z9%H[K<L"
11600 "%a2E-grWVM3@2=-k22tL]4$##6We'8UJCKE[d_=%wI;'6X-GsLX4j^SgJ$##R*w,vP3wK#iiW&#*h^D&R?jp7+/u&#(AP##XU8c$fSYW-J95_-Dp[g9wcO&#M-h1OcJlc-*vpw0xUX&#"
11601 "OQFKNX@QI'IoPp7nb,QU//MQ&ZDkKP)X<WSVL(68uVl&#c'[0#(s1X&xm$Y%B7*K:eDA323j998GXbA#pwMs-jgD$9QISB-A_(aN4xoFM^@C58D0+Q+q3n0#3U1InDjF682-SjMXJK)("
11602 "h$hxua_K]ul92%'BOU&#BRRh-slg8KDlr:%L71Ka:.A;%YULjDPmL<LYs8i#XwJOYaKPKc1h:'9Ke,g)b),78=I39B;xiY$bgGw-&.Zi9InXDuYa%G*f2Bq7mn9^#p1vv%#(Wi-;/Z5h"
11603 "o;#2:;%d	v68C5g?ntX0X)pT`;%pB3q7mgGN)3%(P8nTd5L7GeA-GL@+%J3u2:(Yf>et`e;)f#Km8&+DC$I46>#Kr]]u-[=99tts1.qb#q72g1WJO81q+eN'03'eM>&1XxY-caEnO"
11604 "j%2n8)),?ILR5^.Ibn<-X-Mq7[a82Lq:F&#ce+S9wsCK*x`569E8ew'He]h:sI[2LM$[guka3ZRd6:t%IG:;$%YiJ:Nq=?eAw;/:nnDq0(CYcMpG)qLN4$##&J<j$UpK<Q4a1]MupW^-"
11605 "sj_$%[HK%'F####QRZJ::Y3EGl4'@%FkiAOg#p[##O`gukTfBHagL<LHw%q&OV0##F=6/:chIm0@eCP8X]:kFI%hl8hgO@RcBhS-@Qb$%+m=hPDLg*%K8ln(wcf3/'DW-$.lR?n[nCH-"
11606 "eXOONTJlh:.RYF%3'p6sq:UIMA945&^HFS87@$EP2iG<-lCO$%c`uKGD3rC$x0BL8aFn--`ke%#HMP'vh1/R&O_J9'um,.<tx[@%wsJk&bUT2`0uMv7gg#qp/ij.L56'hl;.s5CUrxjO"
11607 "M7-##.l+Au'A&O:-T72L]P`&=;ctp'XScX*rU.>-XTt,%OVU4)S1+R-#dg0/Nn?Ku1^0f$B*P:Rowwm-`0PKjYDDM'3]d39VZHEl4,.j']Pk-M.h^&:0FACm$maq-&sgw0t7/6(^xtk%"
11608 "LuH88Fj-ekm>GA#_>568x6(OFRl-IZp`&b,_P'$M<Jnq79VsJW/mWS*PUiq76;]/NM_>hLbxfc$mj`,O;&%W2m`Zh:/)Uetw:aJ%]K9h:TcF]u_-Sj9,VK3M.*'&0D[Ca]J9gp8,kAW]"
11609 "%(?A%R$f<->Zts'^kn=-^@c4%-pY6qI%J%1IGxfLU9CP8cbPlXv);C=b),<2mOvP8up,UVf3839acAWAW-W?#ao/^#%KYo8fRULNd2.>%m]UK:n%r$'sw]J;5pAoO_#2mO3n,'=H5(et"
11610 "Hg*`+RLgv>=4U8guD$I%D:W>-r5V*%j*W:Kvej.Lp$<M-SGZ':+Q_k+uvOSLiEo(<aD/K<CCc`'Lx>'?;++O'>()jLR-^u68PHm8ZFWe+ej8h:9r6L*0//c&iH&R8pRbA#Kjm%upV1g:"
11611 "a_#Ur7FuA#(tRh#.Y5K+@?3<-8m0$PEn;J:rh6?I6uG<-`wMU'ircp0LaE_OtlMb&1#6T.#FDKu#1Lw%u%+GM+X'e?YLfjM[VO0MbuFp7;>Q&#WIo)0@F%q7c#4XAXN-U&VB<HFF*qL("
11612 "$/V,;(kXZejWO`<[5?\?ewY(*9=%wDc;,u<'9t3W-(H1th3+G]ucQ]kLs7df($/*JL]@*t7Bu_G3_7mp7<iaQjO@.kLg;x3B0lqp7Hf,^Ze7-##@/c58Mo(3;knp0%)A7?-W+eI'o8)b<"
11613 "nKnw'Ho8C=Y>pqB>0ie&jhZ[?iLR@@_AvA-iQC(=ksRZRVp7`.=+NpBC%rh&3]R:8XDmE5^V8O(x<<aG/1N$#FX$0V5Y6x'aErI3I$7x%E`v<-BY,)%-?Psf*l?%C3.mM(=/M0:JxG'?"
11614 "7WhH%o'a<-80g0NBxoO(GH<dM]n.+%q@jH?f.UsJ2Ggs&4<-e47&Kl+f//9@`b+?.TeN_&B8Ss?v;^Trk;f#YvJkl&w$]>-+k?'(<S:68tq*WoDfZu';mM?8X[ma8W%*`-=;D.(nc7/;"
11615 ")g:T1=^J$&BRV(-lTmNB6xqB[@0*o.erM*<SWF]u2=st-*(6v>^](H.aREZSi,#1:[IXaZFOm<-ui#qUq2$##Ri;u75OK#(RtaW-K-F`S+cF]uN`-KMQ%rP/Xri.LRcB##=YL3BgM/3M"
11616 "D?@f&1'BW-)Ju<L25gl8uhVm1hL$##*8###'A3/LkKW+(^rWX?5W_8g)a(m&K8P>#bmmWCMkk&#TR`C,5d>g)F;t,4:@_l8G/5h4vUd%&%950:VXD'QdWoY-F$BtUwmfe$YqL'8(PWX("
11617 "P?^@Po3$##`MSs?DWBZ/S>+4%>fX,VWv/w'KD`LP5IbH;rTV>n3cEK8U#bX]l-/V+^lj3;vlMb&[5YQ8#pekX9JP3XUC72L,,?+Ni&co7ApnO*5NK,((W-i:$,kp'UDAO(G0Sq7MVjJs"
11618 "bIu)'Z,*[>br5fX^:FPAWr-m2KgL<LUN098kTF&#lvo58=/vjDo;.;)Ka*hLR#/k=rKbxuV`>Q_nN6'8uTGT5g)uLv:873UpTLgH+#FgpH'_o1780Ph8KmxQJ8#H72L4@768@Tm&Q"
11619 "h4CB/5OvmA&,Q&QbUoi$a_%3M01H)4x7I^&KQVgtFnV+;[Pc>[m4k//,]1?#`VY[Jr*3&&slRfLiVZJ:]?=K3Sw=[$=uRB?3xk48@aeg<Z'<$#4H)6,>e0jT6'N#(q%.O=?2S]u*(m<-"
11620 "V8J'(1)G][68hW$5'q[GC&5j`TE?m'esFGNRM)j,ffZ?-qx8;->g4t*:CIP/[Qap7/9'#(1sao7w-.qNUdkJ)tCF&#B^;xGvn2r9FEPFFFcL@.iFNkTve$m%#QvQS8U@)2Z+3K:AKM5i"
11621 "sZ88+dKQ)W6>J%CL<KE>`.d*(B`-n8D9oK<Up]c$X$(,)M8Zt7/[rdkqTgl-0cuGMv'?>-XV1q['-5k'cAZ69e;D_?$ZPP&s^+7])$*$#@QYi9,5P	r+$%CE=68>K8r0=dSC%%(@p7"
11622 ".m7jilQ02'0-VWAg<a/''3u.=4L$Y)6k/K:_[3=&jvL<L0C/2'v:^;-DIBW,B4E68:kZ;%?8(Q8BH=kO65BW?xSG&#@uU,DS*,?.+(o(#1vCS8#CHF>TlGW'b)Tq7VT9q^*^$$.:&N@@"
11623 "$&)WHtPm*5_rO0&e%K&#-30j(E4#'Zb.o/(Tpm$>K'f@[PvFl,hfINTNU6u'0pao7%XUp9]5.>%h`8_=VYbxuel.NTSsJfLacFu3B'lQSu/m6-Oqem8T+oE--$0a/k]uj9EwsG>%veR*"
11624 "hv^BFpQj:K'#SJ,sB-'#](j.Lg92rTw-*n%@/;39rrJF,l#qV%OrtBeC6/,;qB3ebNW[?,Hqj2L.1NP&GjUR=1D8QaS3Up&@*9wP?+lo7b?@%'k4`p0Z$22%K3+iCZj?XJN4Nm&+YF]u"
11625 "@-W$U%VEQ/,,>>#)D<h#`)h0:<Q6909ua+&VU%n2:cG3FJ-%@Bj-DgLr`Hw&HAKjKjseK</xKT*)B,N9X3]krc12t'pgTV(Lv-tL[xg_%=M_q7a^x?7Ubd>#%8cY#YZ?=,`Wdxu/ae&#"
11626 "w6)R89tI#6@s'(6Bf7a&?S=^ZI_kS&ai`&=tE72L_D,;^R)7[$s<Eh#c&)q.MXI%#v9ROa5FZO%sF7q7Nwb&#ptUJ:aqJe$Sl68%.D###EC><?-aF&#RNQv>o8lKN%5/$(vdfq7+ebA#"
11627 "u1p]ovUKW&Y%q]'>$1@-[xfn$7ZTp7mM,G,Ko7a&Gu%G[RMxJs[0MM%wci.LFDK)(<c`Q8N)jEIF*+?P2a8g%)$q]o2aH8C&<SibC/q,(e:v;-b#6[$NtDZ84Je2KNvB#$P5?tQ3nt(0"
11628 "d=j.LQf./Ll33+(;q3L-w=8dX$#WF&uIJ@-bfI>%:_i2B5CsR8&9Z&#=mPEnm0f`<&c)QL5uJ#%u%lJj+D-r;BoFDoS97h5g)E#o:&S4weDF,9^Hoe`h*L+_a*NrLW-1pG_&2UdB8"
11629 "6e%B/:=>)N4xeW.*wft-;$'58-ESqr<b?UI(_%@[P46>#U`'6AQ]m&6/`Z>#S?YY#Vc;r7U2&326d=w&H####?TZ`*4?&.MK?LP8Vxg>$[QXc%QJv92.(Db*B)gb*BM9dM*hJMAo*c&#"
11630 "b0v=Pjer]$gG&JXDf->'StvU7505l9$AFvgYRI^&<^b68?j#q9QX4SM'RO#&sL1IM.rJfLUAj221]d##DW=m83u5;'bYx,*Sl0hL(W;;$doB&O/TQ:(Z^xBdLjL<Lni;''X.`$#8+1GD"
11631 ":k$YUWsbn8ogh6rxZ2Z9]%nd+>V#*8U_72Lh+2Q8Cj0i:6hp&$C/:p(HK>T8Y[gHQ4`4)'$Ab(Nof%V'8hL&#<NEdtg(n'=S1A(Q1/I&4([%dM`,Iu'1:_hL>SfD07&6D<fp8dHM7/g+"
11632 "tlPN9J*rKaPct&?'uBCem^jn%9_K)<,C5K3s=5g&GmJb*[SYq7K;TRLGCsM-$$;S%:Y@r7AK0pprpL<Lrh,q7e/%KWK:50I^+m'vi`3?%Zp+<-d+$L-Sv:@.o19n$s0&39;kn;S%BSq*"
11633 "$3WoJSCLweV[aZ'MQIjO<7;X-X;&+dMLvu#^UsGEC9WEc[X(wI7#2.(F0jV*eZf<-Qv3J-c+J5AlrB#$p(H68LvEA'q3n0#m,[`*8Ft)FcYgEud]CWfm68,(aLA$@EFTgLXoBq/UPlp7"
11634 ":d[/;r_ix=:TF`S5H-b<LI&HY(K=h#)]Lk$K14lVfm:x$H<3^Ql<M`$OhapBnkup'D#L$Pb_`N*g]2e;X/Dtg,bsj&K#2[-:iYr'_wgH)NUIR8a1n#S?Yej'h8^58UbZd+^FKD*T@;6A"
11635 "7aQC[K8d-(v6GI$x:T<&'Gp5Uf>@M.*J:;$-rv29'M]8qMv-tLp,'886iaC=Hb*YJoKJ,(j%K=H`K.v9HggqBIiZu'QvBT.#=)0ukruV&.)3=(^1`o*Pj4<-<aN((^7('#Z0wK#5GX@7"
11636 "u][`*S^43933A4rl][`*O4CgLEl]v$1Q3AeF37dbXk,.)vj#x'd`;qgbQR%FW,2(?LO=s%Sc68%NP'##Aotl8x=BE#j1UD([3$M(]UI2LX3RpKN@;/#f'f/&_mt&F)XdF<9t4)Qa.*kT"
11637 "LwQ'(TTB9.xH'>#MJ+gLq9-##@HuZPN0]u:h7.T..G:;$/Usj(T7`Q8tT72LnYl<-qx8;-HV7Q-&Xdx%1a,hC=0u+HlsV>nuIQL-5<N?)NBS)QN*_I,?&)2'IM%L3I)X((e/dl2&8'<M"
11638 ":^#M*Q+[T.Xri.LYS3v%fF`68h;b-X[/En'CR.q7E)p'/kle2HM,u;^%OKC-N+Ll%F9CF<Nf'^#t2L,;27W:0O@6##U6W7:$rJfLWHj$#)woqBefIZ.PK<b*t7ed;p*_m;4ExK#h@&]>"
11639 "_>@kXQtMacfD.m-VAb8;IReM3$wf0''hra*so568'Ip&vRs849'MRYSp%:t:h5qSgwpEr$B>Q,;s(C#$)`svQuF$##-D,##,g68@2[T;.XSdN9Qe)rpt._K-#5wF)sP'##p#C0c%-Gb%"
11640 "hd+<-j'Ai*x&&HMkT]C'OSl##5RG[JXaHN;d'uA#x._U;.`PU@(Z3dt4r152@:v,'R.Sj'w#0<-;kPI)FfJ&#AYJ&#//)>-k=m=*XnK$>=)72L]0I%>.G690a:$##<,);?;72#?x9+d;"
11641 "^V'9;jY@;)br#q^YQpx:X#Te$Z^'=-=bGhLf:D6&bNwZ9-ZD#n^9HhLMr5G;']d&6'wYmTFmL<LD)F^%[tC'8;+9E#C$g%#5Y>q9wI>P(9mI[>kC-ekLC/R&CH+s'B;K-M6$EB%is00:"
11642 "+A4[7xks.LrNk0&E)wILYF@2L'0Nb$+pv<(2.768/FrY&h$^3i&@+G%JT'<-,v`3;_)I9M^AE]CN?Cl2AZg+%4iTpT3<n-&%H%b<FDj2M<hH=&Eh<2Len$b*aTX=-8QxN)k11IM1c^j%"
11643 "9s<L<NFSo)B?+<-(GxsF,^-Eh@$4dXhN$+#rxK8'je'D7k`e;)2pYwPA'_p9&@^18ml1^[@g4t*[JOa*[=Qp7(qJ_oOL^('7fB&Hq-:sf,sNj8xq^>$U4O]GKx'm9)b@p7YsvK3w^YR-"
11644 "CdQ*:Ir<($u&)#(&?L9Rg3H)4fiEp^iI9O8KnTj,]H?D*r7'M;PwZ9K0E^k&-cpI;.p/6_vwoFMV<->#%Xi.LxVnrU(4&8/P+:hLSKj$#U%]49t'I:rgMi'FL@a:0Y-uA[39',(vbma*"
11645 "hU%<-SRF`Tt:542R_VV$p@[p8DV[A,?1839FWdF<TddF<9Ah-6&9tWoDlh]&1SpGMq>Ti1O*H&#(AL8[_P%.M>v^-))qOT*F5Cq0`Ye%+$B6i:7@0IX<N+T+0MlMBPQ*Vj>SsD<U4JHY"
11646 "8kD2)2fU/M#$e.)T4,_=8hLim[&);?UkK'-x?'(:siIfL<$pFM`i<?%W(mGDHM%>iWP,##P`%/L<eXi:@Z9C.7o=@(pXdAO/NLQ8lPl+HPOQa8wD8=^GlPa8TKI1CjhsCTSLJM'/Wl>-"
11647 "S(qw%sf/@%#B6;/U7K]uZbi^Oc^2n<bhPmUkMw>%t<)'mEVE''n`WnJra$^TKvX5B>;_aSEK',(hwa0:i4G?.Bci.(X[?b*($,=-n<.Q%`(X=?+@Am*Js0&=3bh8K]mL<LoNs'6,'85`"
11648 "0?t/'_U59@]ddF<#LdF<eWdF<OuN/45rY<-L@&#+fm>69=Lb,OcZV/);TTm8VI;?%OtJ<(b4mq7M6:u?KRdF<gR@2L=FNU-<b[(9c/ML3m;Z[$oF3g)GAWqpARc=<ROu7cL5l;-[A]%/"
11649 "+fsd;l#SafT/f*W]0=O'$(Tb<[)*@e775R-:Yob%g*>l*:xP?Yb.5)%w_I?7uk5JC+FS(m#i'k.'a0i)9<7b'fs'59hq$*5Uhv##pi^8+hIEBF`nvo`;'l0.^S1<-wUK2/Coh58KKhLj"
11650 "M=SO*rfO`+qC`W-On.=AJ56>>i2@2LH6A:&5q`?9I3@@'04&p2/LVa*T-4<-i3;M9UvZd+N7>b*eIwg:CC)c<>nO&#<IGe;__.thjZl<%w(Wk2xmp4Q@I#I9,DF]u7-P=.-_:YJ]aS@V"
11651 "?6*C()dOp7:WL,b&3Rg/.cmM9&r^>$(>.Z-I&J(Q0Hd5Q%7Co-b`-c<N(6r@ip+AurK<m86QIth*#v;-OBqi+L7wDE-Ir8K['m+DDSLwK&/.?-V%U_%3:qKNu$_b*B-kp7NaD'QdWQPK"
11652 "Yq[@>P)hI;*_F]u`Rb[.j8_Q/<&>uu+VsH$sM9TA%?)(vmJ80),P7E>)tjD%2L=-t#fK[%`v=Q8<FfNkgg^oIbah*#8/Qt$F&:K*-(N/'+1vMB,u()-a.VUU*#[e%gAAO(S>WlA2);Sa"
11653 ">gXm8YB`1d@K#n]76-a$U,mF<fX]idqd)<3,]J7JmW4`6]uks=4-72L(jEk+:bJ0M^q-8Dm_Z?0olP1C9Sa&H[d&c$ooQUj]Exd*3ZM@-WGW2%s',B-_M%>%Ul:#/'xoFM9QX-$.QN'>"
11654 "[%$Z$uF6pA6Ki2O5:8w*vP1<-1`[G,)-m#>0`P&#eb#.3i)rtB61(o'$?X3B</R90;eZ]%Ncq;-Tl]#F>2Qft^ae_5tKL9MUe9b*sLEQ95C&`=G?@Mj=wh*'3E>=-<)Gt*Iw)'QG:`@I"
11655 "wOf7&]1i'S01B+Ev/Nac#9S;=;YQpg_6U`*kVY39xK,[/6Aj7:'1Bm-_1EYfa1+o&o4hp7KN_Q(OlIo@S%;jVdn0'1<Vc52=u`3^o-n1'g4v58Hj&6_t7$##?M)c<$bgQ_'SY((-xkA#"
11656 "Y(,p'H9rIVY-b,'%bCPF7.J<Up^,(dU1VY*5#WkTU>h19w,WQhLI)3S#f$2(eb,jr*b;3Vw]*7NH%$c4Vs,eD9>XW8?N]o+(*pgC%/72LV-u<Hp,3@e^9UB1J+ak9-TN/mhKPg+AJYd$"
11657 "MlvAF_jCK*.O-^(63adMT->W%iewS8W6m2rtCpo'RS1R84=@paTKt)>=%&1[)*vp'u+x,VrwN;&]kuO9JDbg=pO$J*.jVe;u'm0dr9l,<*wMK*Oe=g8lV_KEBFkO'oU]^=[-792#ok,)"
11658 "i]lR8qQ2oA8wcRCZ^7w/Njh;?.stX?Q1>S1q4Bn$)K1<-rGdO'$Wr.Lc.CG)$/*JL4tNR/,SVO3,aUw'DJN:)Ss;wGn9A32ijw%FL+Z0Fn.U9;reSq)bmI32U==5ALuG&#Vf1398/pVo"
11659 "1*c-(aY168o<`JsSbk-,1N;$>0:OUas(3:8Z972LSfF8eb=c-;>SPw7.6hn3m`9^Xkn(r.qS[0;T%&Qc=+STRxX'q1BNk3&*eu2;&8q$&x>Q#Q7^Tf+6<(d%ZVmj2bDi%.3L2n+4W'$P"
11660 "iDDG)g,r%+?,$@?uou5tSe2aN_AQU*<h`e-GI7)?OK2A.d7_c)?wQ5AS@DL3r#7fSkgl6-++D:'A,uq7SvlB$pcpH'q3n0#_%dY#xCpr-l<F0NR@-##FEV6NTF6##$l84N1w?AO>'IAO"
11661 "URQ##V^Fv-XFbGM7Fl(N<3DhLGF%q.1rC$#:T__&Pi68%0xi_&[qFJ(77j_&JWoF.V735&T,[R*:xFR*K5>>#`bW-?4Ne_&6Ne_&6Ne_&n`kr-#GJcM6X;uM6X;uM(.a..^2TkL%oR(#"
11662 ";u.T%fAr%4tJ8&><1=GHZ_+m9/#H1F^R#SC#*N=BA9(D?v[UiFY>>^8p,KKF.W]L29uLkLlu/+4T<XoIB&hx=T1PcDaB&;HH+-AFr?(m9HZV)FKS8JCw;SD=6[^/DZUL`EUDf]GGlG&>"
11663 "w$)F./^n3+rlo+DB;5sIYGNk+i1t-69Jg--0pao7Sm#K)pdHW&;LuDNH@H>#/X-TI(;P>#,Gc>#0Su>#4`1?#8lC?#<xU?#@.i?#D:%@#HF7@#LRI@#P_[@#Tkn@#Xw*A#]-=A#a9OA#"
11664 "d<F&#*;G##.GY##2Sl##6`($#:l:$#>xL$#B.`$#F:r$#JF.%#NR@%#R_R%#Vke%#Zww%#_-4^Rh%Sflr-k'MS.o?.5/sWel/wpEM0%3'/1)K^f1-d>G21&v(35>V`39V7A4=onx4"
11665 "A1OY5EI0;6Ibgr6M$HS7Q<)58C5w,;WoA*#[%T*#`1g*#d=#+#hI5+#lUG+#pbY+#tnl+#x$),#&1;,#*=M,#.I`,#2Ur,#6b.-#;w[H#iQtA#m^0B#qjBB#uvTB##-hB#'9$C#+E6C#"
11666 "/QHC#3^ZC#7jmC#;v)D#?,<D#C8ND#GDaD#KPsD#O]/E#g1A5#KA*1#gC17#MGd;#8(02#L-d3#rWM4#Hga1#,<w0#T.j<#O#'2#CYN1#qa^:#_4m3#o@/=#eG8=#t8J5#`+78#4uI-#"
11667 "m3B2#SB[8#Q0@8#i[*9#iOn8#1Nm;#^sN9#qh<9#:=x-#P;K2#$%X9#bC+.#Rg;<#mN=.#MTF.#RZO.#2?)4#Y#(/#[)1/#b;L/#dAU/#0Sv;#lY$0#n`-0#sf60#(F24#wrH0#%/e0#"
11668 "TmD<#%JSMFove:CTBEXI:<eh2g)B,3h2^G3i;#d3jD>)4kMYD4lVu`4m`:&5niUA5@(A5BA1]PBB:xlBCC=2CDLXMCEUtiCf&0g2'tN?PGT4CPGT4CPGT4CPGT4CPGT4CPGT4CPGT4CP"
11669 "GT4CPGT4CPGT4CPGT4CPGT4CPGT4CP-qekC`.9kEg^+F$kwViFJTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5o,^<-28ZI'O?;xp"
11670 "O?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xp;7q-#lLYI:xvD=#";
11673 #define NK_CURSOR_DATA_W 90
11674 #define NK_CURSOR_DATA_H 27
11675 NK_GLOBAL const char nk_custom_cursor_data[NK_CURSOR_DATA_W * NK_CURSOR_DATA_H + 1] =
11677 "..- -XXXXXXX- X - X -XXXXXXX - XXXXXXX"
11678 "..- -X.....X- X.X - X.X -X.....X - X.....X"
11679 "--- -XXX.XXX- X...X - X...X -X....X - X....X"
11680 "X - X.X - X.....X - X.....X -X...X - X...X"
11681 "XX - X.X -X.......X- X.......X -X..X.X - X.X..X"
11682 "X.X - X.X -XXXX.XXXX- XXXX.XXXX -X.X X.X - X.X X.X"
11683 "X..X - X.X - X.X - X.X -XX X.X - X.X XX"
11684 "X...X - X.X - X.X - XX X.X XX - X.X - X.X "
11685 "X....X - X.X - X.X - X.X X.X X.X - X.X - X.X "
11686 "X.....X - X.X - X.X - X..X X.X X..X - X.X - X.X "
11687 "X......X - X.X - X.X - X...XXXXXX.XXXXXX...X - X.X XX-XX X.X "
11688 "X.......X - X.X - X.X -X.....................X- X.X X.X-X.X X.X "
11689 "X........X - X.X - X.X - X...XXXXXX.XXXXXX...X - X.X..X-X..X.X "
11690 "X.........X -XXX.XXX- X.X - X..X X.X X..X - X...X-X...X "
11691 "X..........X-X.....X- X.X - X.X X.X X.X - X....X-X....X "
11692 "X......XXXXX-XXXXXXX- X.X - XX X.X XX - X.....X-X.....X "
11693 "X...X..X --------- X.X - X.X - XXXXXXX-XXXXXXX "
11694 "X..X X..X - -XXXX.XXXX- XXXX.XXXX ------------------------------------"
11695 "X.X X..X - -X.......X- X.......X - XX XX - "
11696 "XX X..X - - X.....X - X.....X - X.X X.X - "
11697 " X..X - X...X - X...X - X..X X..X - "
11698 " XX - X.X - X.X - X...XXXXXXXXXXXXX...X - "
11699 "------------ - X - X -X.....................X- "
11700 " ----------------------------------- X...XXXXXXXXXXXXX...X - "
11707 #pragma clang diagnostic pop
11708 #elif defined(__GNUC__) || defined(__GNUG__)
11709 #pragma GCC diagnostic pop
11713 nk_decompress_length(
unsigned char *input)
11715 return (
unsigned int)((input[8] << 24) + (input[9] << 16) + (input[10] << 8) + input[11]);
11725 nk__match(
unsigned char *data,
unsigned int length)
11728 NK_ASSERT (nk__dout + length <= nk__barrier);
11729 if (nk__dout + length > nk__barrier) { nk__dout += length;
return; }
11730 if (data < nk__barrier4) { nk__dout = nk__barrier+1;
return; }
11731 while (length--) *nk__dout++ = *data++;
11735 nk__lit(
unsigned char *data,
unsigned int length)
11737 NK_ASSERT (nk__dout + length <= nk__barrier);
11738 if (nk__dout + length > nk__barrier) { nk__dout += length;
return; }
11739 if (data < nk__barrier2) { nk__dout = nk__barrier+1;
return; }
11740 NK_MEMCPY(nk__dout, data, length);
11741 nk__dout += length;
11744 #define nk__in2(x) ((i[x] << 8) + i[(x)+1])
11745 #define nk__in3(x) ((i[x] << 16) + nk__in2((x)+1))
11746 #define nk__in4(x) ((i[x] << 24) + nk__in3((x)+1))
11749 nk_decompress_token(
unsigned char *i)
11752 if (*i >= 0x80) nk__match(nk__dout-i[1]-1, (
unsigned int)i[0] - 0x80 + 1), i += 2;
11753 else if (*i >= 0x40) nk__match(nk__dout-(nk__in2(0) - 0x4000 + 1), (
unsigned int)i[2]+1), i += 3;
11754 else nk__lit(i+1, (
unsigned int)i[0] - 0x20 + 1), i += 1 + (i[0] - 0x20 + 1);
11756 if (*i >= 0x18) nk__match(nk__dout-(
unsigned int)(nk__in3(0) - 0x180000 + 1), (
unsigned int)i[3]+1), i += 4;
11757 else if (*i >= 0x10) nk__match(nk__dout-(
unsigned int)(nk__in3(0) - 0x100000 + 1), (
unsigned int)nk__in2(3)+1), i += 5;
11758 else if (*i >= 0x08) nk__lit(i+2, (
unsigned int)nk__in2(0) - 0x0800 + 1), i += 2 + (nk__in2(0) - 0x0800 + 1);
11759 else if (*i == 0x07) nk__lit(i+3, (
unsigned int)nk__in2(1) + 1), i += 3 + (nk__in2(1) + 1);
11760 else if (*i == 0x06) nk__match(nk__dout-(
unsigned int)(nk__in3(1)+1), i[4]+1u), i += 5;
11761 else if (*i == 0x04) nk__match(nk__dout-(
unsigned int)(nk__in3(1)+1), (
unsigned int)nk__in2(4)+1u), i += 6;
11767 nk_adler32(
unsigned int adler32,
unsigned char *buffer,
unsigned int buflen)
11769 const unsigned long ADLER_MOD = 65521;
11770 unsigned long s1 = adler32 & 0xffff, s2 = adler32 >> 16;
11771 unsigned long blocklen, i;
11773 blocklen = buflen % 5552;
11775 for (i=0; i + 7 < blocklen; i += 8) {
11776 s1 += buffer[0]; s2 += s1;
11777 s1 += buffer[1]; s2 += s1;
11778 s1 += buffer[2]; s2 += s1;
11779 s1 += buffer[3]; s2 += s1;
11780 s1 += buffer[4]; s2 += s1;
11781 s1 += buffer[5]; s2 += s1;
11782 s1 += buffer[6]; s2 += s1;
11783 s1 += buffer[7]; s2 += s1;
11786 for (; i < blocklen; ++i) {
11787 s1 += *buffer++; s2 += s1;
11790 s1 %= ADLER_MOD; s2 %= ADLER_MOD;
11791 buflen -= (
unsigned int)blocklen;
11794 return (
unsigned int)(s2 << 16) + (
unsigned int)s1;
11798 nk_decompress(
unsigned char *output,
unsigned char *i,
unsigned int length)
11801 if (nk__in4(0) != 0x57bC0000)
return 0;
11802 if (nk__in4(4) != 0)
return 0;
11803 olen = nk_decompress_length(i);
11805 nk__barrier3 = i+length;
11806 nk__barrier = output + olen;
11812 unsigned char *old_i = i;
11813 i = nk_decompress_token(i);
11815 if (*i == 0x05 && i[1] == 0xfa) {
11816 NK_ASSERT(nk__dout == output + olen);
11817 if (nk__dout != output + olen)
return 0;
11818 if (nk_adler32(1, output, olen) != (
unsigned int) nk__in4(2))
11826 NK_ASSERT(nk__dout <= output + olen);
11827 if (nk__dout > output + olen)
11833 nk_decode_85_byte(
char c)
11834 {
return (
unsigned int)((c >=
'\\') ? c-36 : c-35); }
11837 nk_decode_85(
unsigned char* dst,
const unsigned char* src)
11842 nk_decode_85_byte((
char)src[0]) +
11843 85 * (nk_decode_85_byte((
char)src[1]) +
11844 85 * (nk_decode_85_byte((
char)src[2]) +
11845 85 * (nk_decode_85_byte((
char)src[3]) +
11846 85 * nk_decode_85_byte((
char)src[4]))));
11849 dst[0] = (
unsigned char)((tmp >> 0) & 0xFF);
11850 dst[1] = (
unsigned char)((tmp >> 8) & 0xFF);
11851 dst[2] = (
unsigned char)((tmp >> 16) & 0xFF);
11852 dst[3] = (
unsigned char)((tmp >> 24) & 0xFF);
11864 NK_API struct nk_font_config
11865 nk_font_config(float pixel_height)
11867 struct nk_font_config cfg;
11871 cfg.ttf_data_owned_by_atlas = 0;
11872 cfg.size = pixel_height;
11873 cfg.oversample_h = 3;
11874 cfg.oversample_v = 1;
11875 cfg.pixel_snap = 0;
11876 cfg.coord_type = NK_COORD_UV;
11878 cfg.range = nk_font_default_glyph_ranges();
11879 cfg.merge_mode = 0;
11880 cfg.fallback_glyph =
'?';
11885 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
11887 nk_font_atlas_init_default(
struct nk_font_atlas *atlas)
11890 if (!atlas)
return;
11892 atlas->temporary.userdata.ptr = 0;
11893 atlas->temporary.alloc = nk_malloc;
11894 atlas->temporary.free = nk_mfree;
11895 atlas->permanent.userdata.ptr = 0;
11896 atlas->permanent.alloc = nk_malloc;
11897 atlas->permanent.free = nk_mfree;
11902 nk_font_atlas_init(
struct nk_font_atlas *atlas,
struct nk_allocator *alloc)
11906 if (!atlas || !alloc)
return;
11908 atlas->permanent = *alloc;
11909 atlas->temporary = *alloc;
11913 nk_font_atlas_init_custom(
struct nk_font_atlas *atlas,
11917 NK_ASSERT(permanent);
11918 NK_ASSERT(temporary);
11919 if (!atlas || !permanent || !temporary)
return;
11921 atlas->permanent = *permanent;
11922 atlas->temporary = *temporary;
11926 nk_font_atlas_begin(
struct nk_font_atlas *atlas)
11929 NK_ASSERT(atlas->temporary.alloc && atlas->temporary.free);
11930 NK_ASSERT(atlas->permanent.alloc && atlas->permanent.free);
11931 if (!atlas || !atlas->permanent.alloc || !atlas->permanent.free ||
11932 !atlas->temporary.alloc || !atlas->temporary.free)
return;
11933 if (atlas->glyphs) {
11934 atlas->permanent.free(atlas->permanent.userdata, atlas->glyphs);
11937 if (atlas->pixel) {
11938 atlas->permanent.free(atlas->permanent.userdata, atlas->pixel);
11944 nk_font_atlas_add(
struct nk_font_atlas *atlas,
const struct nk_font_config *config)
11946 struct nk_font *font = 0;
11947 struct nk_font_config *cfg;
11950 NK_ASSERT(atlas->permanent.alloc);
11951 NK_ASSERT(atlas->permanent.free);
11952 NK_ASSERT(atlas->temporary.alloc);
11953 NK_ASSERT(atlas->temporary.free);
11956 NK_ASSERT(config->ttf_blob);
11957 NK_ASSERT(config->ttf_size);
11958 NK_ASSERT(config->size > 0.0f);
11960 if (!atlas || !config || !config->ttf_blob || !config->ttf_size || config->size <= 0.0f||
11961 !atlas->permanent.alloc || !atlas->permanent.free ||
11962 !atlas->temporary.alloc || !atlas->temporary.free)
11966 cfg = (
struct nk_font_config*)
11967 atlas->permanent.alloc(atlas->permanent.userdata,0,
sizeof(
struct nk_font_config));
11968 NK_MEMCPY(cfg, config,
sizeof(*config));
11969 if (!atlas->config) {
11970 atlas->config = cfg;
11973 cfg->next = atlas->config;
11974 atlas->config = cfg;
11978 if (!config->merge_mode) {
11979 font = (
struct nk_font*)
11980 atlas->permanent.alloc(atlas->permanent.userdata,0,
sizeof(
struct nk_font));
11982 if (!font)
return 0;
11983 font->config = cfg;
11985 NK_ASSERT(atlas->font_num);
11986 font = atlas->fonts;
11987 font->config = cfg;
11991 if (!config->merge_mode) {
11992 if (!atlas->fonts) {
11993 atlas->fonts = font;
11996 font->next = atlas->fonts;
11997 atlas->fonts = font;
11999 cfg->font = &font->info;
12003 if (!config->ttf_data_owned_by_atlas) {
12004 cfg->ttf_blob = atlas->permanent.alloc(atlas->permanent.userdata,0, cfg->ttf_size);
12005 NK_ASSERT(cfg->ttf_blob);
12006 if (!cfg->ttf_blob) {
12010 NK_MEMCPY(cfg->ttf_blob, config->ttf_blob, cfg->ttf_size);
12011 cfg->ttf_data_owned_by_atlas = 1;
12018 nk_font_atlas_add_from_memory(
struct nk_font_atlas *atlas,
void *memory,
12019 nk_size size,
float height,
const struct nk_font_config *config)
12021 struct nk_font_config cfg;
12026 NK_ASSERT(atlas->temporary.alloc);
12027 NK_ASSERT(atlas->temporary.free);
12028 NK_ASSERT(atlas->permanent.alloc);
12029 NK_ASSERT(atlas->permanent.free);
12030 if (!atlas || !atlas->temporary.alloc || !atlas->temporary.free || !memory || !size ||
12031 !atlas->permanent.alloc || !atlas->permanent.free)
12034 cfg = (
config) ? *config: nk_font_config(height);
12035 cfg.ttf_blob = memory;
12036 cfg.ttf_size = size;
12038 cfg.ttf_data_owned_by_atlas = 0;
12039 return nk_font_atlas_add(atlas, &cfg);
12042 #ifdef NK_INCLUDE_STANDARD_IO
12044 nk_font_atlas_add_from_file(
struct nk_font_atlas *atlas,
const char *file_path,
12045 float height,
const struct nk_font_config *config)
12049 struct nk_font_config cfg;
12052 NK_ASSERT(atlas->temporary.alloc);
12053 NK_ASSERT(atlas->temporary.free);
12054 NK_ASSERT(atlas->permanent.alloc);
12055 NK_ASSERT(atlas->permanent.free);
12057 if (!atlas || !file_path)
return 0;
12058 memory = nk_file_load(file_path, &size, &atlas->permanent);
12059 if (!memory)
return 0;
12061 cfg = (
config) ? *config: nk_font_config(height);
12062 cfg.ttf_blob = memory;
12063 cfg.ttf_size = size;
12065 cfg.ttf_data_owned_by_atlas = 1;
12066 return nk_font_atlas_add(atlas, &cfg);
12071 nk_font_atlas_add_compressed(
struct nk_font_atlas *atlas,
12072 void *compressed_data, nk_size compressed_size,
float height,
12073 const struct nk_font_config *config)
12075 unsigned int decompressed_size;
12076 void *decompressed_data;
12077 struct nk_font_config cfg;
12080 NK_ASSERT(atlas->temporary.alloc);
12081 NK_ASSERT(atlas->temporary.free);
12082 NK_ASSERT(atlas->permanent.alloc);
12083 NK_ASSERT(atlas->permanent.free);
12085 NK_ASSERT(compressed_data);
12086 NK_ASSERT(compressed_size);
12087 if (!atlas || !compressed_data || !atlas->temporary.alloc || !atlas->temporary.free ||
12088 !atlas->permanent.alloc || !atlas->permanent.free)
12091 decompressed_size = nk_decompress_length((
unsigned char*)compressed_data);
12092 decompressed_data = atlas->permanent.alloc(atlas->permanent.userdata,0,decompressed_size);
12093 NK_ASSERT(decompressed_data);
12094 if (!decompressed_data)
return 0;
12095 nk_decompress((
unsigned char*)decompressed_data, (
unsigned char*)compressed_data,
12096 (
unsigned int)compressed_size);
12098 cfg = (
config) ? *config: nk_font_config(height);
12099 cfg.ttf_blob = decompressed_data;
12100 cfg.ttf_size = decompressed_size;
12102 cfg.ttf_data_owned_by_atlas = 1;
12103 return nk_font_atlas_add(atlas, &cfg);
12107 nk_font_atlas_add_compressed_base85(
struct nk_font_atlas *atlas,
12108 const char *data_base85,
float height,
const struct nk_font_config *config)
12110 int compressed_size;
12111 void *compressed_data;
12112 struct nk_font *font;
12115 NK_ASSERT(atlas->temporary.alloc);
12116 NK_ASSERT(atlas->temporary.free);
12117 NK_ASSERT(atlas->permanent.alloc);
12118 NK_ASSERT(atlas->permanent.free);
12120 NK_ASSERT(data_base85);
12121 if (!atlas || !data_base85 || !atlas->temporary.alloc || !atlas->temporary.free ||
12122 !atlas->permanent.alloc || !atlas->permanent.free)
12125 compressed_size = (((
int)
nk_strlen(data_base85) + 4) / 5) * 4;
12126 compressed_data = atlas->temporary.alloc(atlas->temporary.userdata,0, (nk_size)compressed_size);
12127 NK_ASSERT(compressed_data);
12128 if (!compressed_data)
return 0;
12129 nk_decode_85((
unsigned char*)compressed_data, (
const unsigned char*)data_base85);
12130 font = nk_font_atlas_add_compressed(atlas, compressed_data,
12131 (nk_size)compressed_size, height, config);
12132 atlas->temporary.free(atlas->temporary.userdata, compressed_data);
12136 #ifdef NK_INCLUDE_DEFAULT_FONT
12138 nk_font_atlas_add_default(
struct nk_font_atlas *atlas,
12139 float pixel_height,
const struct nk_font_config *config)
12142 NK_ASSERT(atlas->temporary.alloc);
12143 NK_ASSERT(atlas->temporary.free);
12144 NK_ASSERT(atlas->permanent.alloc);
12145 NK_ASSERT(atlas->permanent.free);
12146 return nk_font_atlas_add_compressed_base85(atlas,
12147 nk_proggy_clean_ttf_compressed_data_base85, pixel_height, config);
12152 nk_font_atlas_bake(
struct nk_font_atlas *atlas,
int *width,
int *height,
12153 enum nk_font_atlas_format fmt)
12157 nk_size tmp_size, img_size;
12158 struct nk_font *font_iter;
12159 struct nk_font_baker *baker;
12162 NK_ASSERT(atlas->temporary.alloc);
12163 NK_ASSERT(atlas->temporary.free);
12164 NK_ASSERT(atlas->permanent.alloc);
12165 NK_ASSERT(atlas->permanent.free);
12169 if (!atlas || !width || !height ||
12170 !atlas->temporary.alloc || !atlas->temporary.free ||
12171 !atlas->permanent.alloc || !atlas->permanent.free)
12174 #ifdef NK_INCLUDE_DEFAULT_FONT
12176 if (!atlas->font_num)
12177 atlas->default_font = nk_font_atlas_add_default(atlas, 13.0f, 0);
12179 NK_ASSERT(atlas->font_num);
12180 if (!atlas->font_num)
return 0;
12183 nk_font_baker_memory(&tmp_size, &atlas->glyph_count, atlas->config, atlas->font_num);
12184 tmp = atlas->temporary.alloc(atlas->temporary.userdata,0, tmp_size);
12186 if (!tmp)
goto failed;
12189 baker = nk_font_baker(tmp, atlas->glyph_count, atlas->font_num, &atlas->temporary);
12190 atlas->glyphs = (
struct nk_font_glyph*)atlas->permanent.alloc(
12191 atlas->permanent.userdata,0,
sizeof(
struct nk_font_glyph)*(nk_size)atlas->glyph_count);
12192 NK_ASSERT(atlas->glyphs);
12193 if (!atlas->glyphs)
12197 atlas->custom.w = (NK_CURSOR_DATA_W*2)+1;
12198 atlas->custom.h = NK_CURSOR_DATA_H + 1;
12199 if (!nk_font_bake_pack(baker, &img_size, width, height, &atlas->custom,
12200 atlas->config, atlas->font_num, &atlas->temporary))
12204 atlas->pixel = atlas->temporary.alloc(atlas->temporary.userdata,0, img_size);
12205 NK_ASSERT(atlas->pixel);
12210 nk_font_bake(baker, atlas->pixel, *width, *height,
12211 atlas->glyphs, atlas->glyph_count, atlas->config, atlas->font_num);
12212 nk_font_bake_custom_data(atlas->pixel, *width, *height, atlas->custom,
12213 nk_custom_cursor_data, NK_CURSOR_DATA_W, NK_CURSOR_DATA_H,
'.',
'X');
12215 if (fmt == NK_FONT_ATLAS_RGBA32) {
12217 void *img_rgba = atlas->temporary.alloc(atlas->temporary.userdata,0,
12218 (nk_size)(*width * *height * 4));
12219 NK_ASSERT(img_rgba);
12220 if (!img_rgba)
goto failed;
12221 nk_font_bake_convert(img_rgba, *width, *height, atlas->pixel);
12222 atlas->temporary.free(atlas->temporary.userdata, atlas->pixel);
12223 atlas->pixel = img_rgba;
12225 atlas->tex_width = *width;
12226 atlas->tex_height = *height;
12229 for (font_iter = atlas->fonts; font_iter; font_iter = font_iter->next) {
12230 struct nk_font *font = font_iter;
12231 struct nk_font_config *config = font->config;
12232 nk_font_init(font, config->size, config->fallback_glyph, atlas->glyphs,
12239 {{ 0, 3}, {12,19}, { 0, 0}},
12240 {{13, 0}, { 7,16}, { 4, 8}},
12241 {{31, 0}, {23,23}, {11,11}},
12242 {{21, 0}, { 9, 23}, { 5,11}},
12243 {{55,18}, {23, 9}, {11, 5}},
12244 {{73, 0}, {17,17}, { 9, 9}},
12245 {{55, 0}, {17,17}, { 9, 9}}
12248 struct nk_cursor *cursor = &atlas->cursors[i];
12249 cursor->
img.
w = (
unsigned short)*width;
12250 cursor->
img.
h = (
unsigned short)*height;
12251 cursor->
img.
region[0] = (
unsigned short)(atlas->custom.x + nk_cursor_data[i][0].
x);
12252 cursor->
img.
region[1] = (
unsigned short)(atlas->custom.y + nk_cursor_data[i][0].
y);
12253 cursor->
img.
region[2] = (
unsigned short)nk_cursor_data[i][1].x;
12254 cursor->
img.
region[3] = (
unsigned short)nk_cursor_data[i][1].y;
12255 cursor->size = nk_cursor_data[i][1];
12256 cursor->
offset = nk_cursor_data[i][2];
12259 atlas->temporary.free(atlas->temporary.userdata, tmp);
12260 return atlas->pixel;
12264 if (tmp) atlas->temporary.free(atlas->temporary.userdata, tmp);
12265 if (atlas->glyphs) {
12266 atlas->permanent.free(atlas->permanent.userdata, atlas->glyphs);
12269 if (atlas->pixel) {
12270 atlas->temporary.free(atlas->temporary.userdata, atlas->pixel);
12277 nk_font_atlas_end(
struct nk_font_atlas *atlas, nk_handle texture,
12281 struct nk_font *font_iter;
12290 null->
uv.
x = (atlas->custom.x + 0.5f)/(
float)atlas->tex_width;
12291 null->
uv.
y = (atlas->custom.y + 0.5f)/(
float)atlas->tex_height;
12293 for (font_iter = atlas->fonts; font_iter; font_iter = font_iter->next) {
12294 font_iter->texture =
texture;
12295 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
12296 font_iter->handle.texture =
texture;
12300 atlas->cursors[i].img.handle = texture;
12302 atlas->temporary.free(atlas->temporary.userdata, atlas->pixel);
12304 atlas->tex_width = 0;
12305 atlas->tex_height = 0;
12306 atlas->custom.x = 0;
12307 atlas->custom.y = 0;
12308 atlas->custom.w = 0;
12309 atlas->custom.h = 0;
12313 nk_font_atlas_cleanup(
struct nk_font_atlas *atlas)
12316 NK_ASSERT(atlas->temporary.alloc);
12317 NK_ASSERT(atlas->temporary.free);
12318 NK_ASSERT(atlas->permanent.alloc);
12319 NK_ASSERT(atlas->permanent.free);
12321 if (!atlas || !atlas->permanent.alloc || !atlas->permanent.free)
return;
12322 if (atlas->config) {
12323 struct nk_font_config *iter, *next;
12324 for (iter = atlas->config; iter; iter = next) {
12326 atlas->permanent.free(atlas->permanent.userdata, iter->ttf_blob);
12327 atlas->permanent.free(atlas->permanent.userdata, iter);
12333 nk_font_atlas_clear(
struct nk_font_atlas *atlas)
12336 NK_ASSERT(atlas->temporary.alloc);
12337 NK_ASSERT(atlas->temporary.free);
12338 NK_ASSERT(atlas->permanent.alloc);
12339 NK_ASSERT(atlas->permanent.free);
12340 if (!atlas || !atlas->permanent.alloc || !atlas->permanent.free)
return;
12342 nk_font_atlas_cleanup(atlas);
12343 if (atlas->fonts) {
12344 struct nk_font *iter, *next;
12345 for (iter = atlas->fonts; iter; iter = next) {
12347 atlas->permanent.free(atlas->permanent.userdata, iter);
12352 atlas->permanent.free(atlas->permanent.userdata, atlas->glyphs);
12637 struct nk_text_find {
12640 int first_char, length;
12644 struct nk_text_edit_row {
12647 float baseline_y_delta;
12658 #define NK_TEXT_HAS_SELECTION(s) ((s)->select_start != (s)->select_end)
12661 nk_textedit_get_width(
const struct nk_text_edit *edit,
int line_start,
int char_id,
12665 nk_rune unicode = 0;
12671 nk_textedit_layout_row(
struct nk_text_edit_row *r,
struct nk_text_edit *edit,
12672 int line_start_id,
float row_height,
const struct nk_user_font *font)
12677 const char *remaining;
12681 const struct nk_vec2 size = nk_text_calculate_text_bounds(font,
12682 text, (
int)(end - text), row_height, &remaining, 0, &glyphs, NK_STOP_ON_NEW_LINE);
12686 r->baseline_y_delta = size.
y;
12689 r->num_chars = glyphs;
12693 nk_textedit_locate_coord(
struct nk_text_edit *edit,
float x,
float y,
12696 struct nk_text_edit_row r;
12698 float base_y = 0, prev_x;
12702 r.ymin = r.ymax = 0;
12707 nk_textedit_layout_row(&r, edit, i, row_height, font);
12708 if (r.num_chars <= 0)
12711 if (i==0 && y < base_y + r.ymin)
12714 if (y < base_y + r.ymax)
12718 base_y += r.baseline_y_delta;
12734 for (i=0; i < r.num_chars; ++i) {
12735 float w = nk_textedit_get_width(edit, k, i, font);
12736 if (x < prev_x+w) {
12737 if (x < prev_x+w/2)
12749 return i+r.num_chars-1;
12750 else return i+r.num_chars;
12754 nk_textedit_click(
struct nk_text_edit *state,
float x,
float y,
12759 state->
cursor = nk_textedit_locate_coord(state, x, y, font, row_height);
12766 nk_textedit_drag(
struct nk_text_edit *state,
float x,
float y,
12771 int p = nk_textedit_locate_coord(state, x, y, font, row_height);
12778 nk_textedit_find_charpos(
struct nk_text_find *find,
struct nk_text_edit *state,
12779 int n,
int single_line,
const struct nk_user_font *font,
float row_height)
12783 struct nk_text_edit_row r;
12784 int prev_start = 0;
12792 nk_textedit_layout_row(&r, state, 0, row_height, font);
12794 find->first_char = 0;
12800 nk_textedit_layout_row(&r, state, i, row_height, font);
12803 find->first_char = i;
12804 find->length = r.num_chars;
12808 find->height = r.ymax - r.ymin;
12809 find->prev_first = prev_start;
12817 nk_textedit_layout_row(&r, state, i, row_height, font);
12818 if (n < i + r.num_chars)
break;
12821 find->y += r.baseline_y_delta;
12824 find->first_char = first = i;
12825 find->length = r.num_chars;
12826 find->height = r.ymax - r.ymin;
12827 find->prev_first = prev_start;
12831 for (i=0; first+i < n; ++i)
12832 find->x += nk_textedit_get_width(state, first, i, font);
12840 if (NK_TEXT_HAS_SELECTION(state)) {
12854 nk_textedit_makeundo_delete(state, where, len);
12863 nk_textedit_clamp(state);
12864 if (NK_TEXT_HAS_SELECTION(state)) {
12893 if (NK_TEXT_HAS_SELECTION(state)) {
12894 nk_textedit_sortselection(state);
12905 if (NK_TEXT_HAS_SELECTION(state)) {
12906 nk_textedit_sortselection(state);
12907 nk_textedit_clamp(state);
12915 nk_is_word_boundary(
struct nk_text_edit *state,
int idx)
12919 if (idx <= 0)
return 1;
12921 return (c ==
' ' || c ==
'\t' ||c == 0x3000 || c ==
',' || c ==
';' ||
12922 c ==
'(' || c ==
')' || c ==
'{' || c ==
'}' || c ==
'[' || c ==
']' ||
12927 nk_textedit_move_to_word_previous(
struct nk_text_edit *state)
12929 int c = state->
cursor - 1;
12930 while( c >= 0 && !nk_is_word_boundary(state, c))
12940 nk_textedit_move_to_word_next(
struct nk_text_edit *state)
12943 int c = state->
cursor+1;
12944 while( c < len && !nk_is_word_boundary(state, c))
12954 nk_textedit_prep_selection_at_cursor(
struct nk_text_edit *state)
12957 if (!NK_TEXT_HAS_SELECTION(state))
12968 if (NK_TEXT_HAS_SELECTION(state)) {
12981 const char *text = (
const char *) ctext;
12985 nk_textedit_clamp(state);
12991 nk_textedit_makeundo_insert(state, state->
cursor, glyphs);
13014 while ((text_len < total_len) && glyph_len)
13017 if (unicode == 127)
goto next;
13019 if (unicode ==
'\n' && state->
single_line)
goto next;
13021 if (state->
filter && !state->
filter(state, unicode))
goto next;
13023 if (!NK_TEXT_HAS_SELECTION(state) &&
13027 nk_textedit_makeundo_replace(state, state->
cursor, 1, 1);
13041 nk_textedit_makeundo_insert(state, state->
cursor, 1);
13047 text_len += glyph_len;
13048 glyph_len =
nk_utf_decode(text + text_len, &unicode, total_len-text_len);
13100 nk_textedit_clamp(state);
13101 nk_textedit_prep_selection_at_cursor(state);
13110 if (NK_TEXT_HAS_SELECTION(state))
13111 nk_textedit_move_to_first(state);
13112 else if (state->
cursor > 0)
13119 nk_textedit_prep_selection_at_cursor(state);
13122 nk_textedit_clamp(state);
13128 if (NK_TEXT_HAS_SELECTION(state))
13129 nk_textedit_move_to_last(state);
13131 nk_textedit_clamp(state);
13137 if( !NK_TEXT_HAS_SELECTION( state ) )
13138 nk_textedit_prep_selection_at_cursor(state);
13139 state->
cursor = nk_textedit_move_to_word_previous(state);
13141 nk_textedit_clamp(state );
13143 if (NK_TEXT_HAS_SELECTION(state))
13144 nk_textedit_move_to_first(state);
13146 state->
cursor = nk_textedit_move_to_word_previous(state);
13147 nk_textedit_clamp(state );
13153 if( !NK_TEXT_HAS_SELECTION( state ) )
13154 nk_textedit_prep_selection_at_cursor(state);
13155 state->
cursor = nk_textedit_move_to_word_next(state);
13157 nk_textedit_clamp(state);
13159 if (NK_TEXT_HAS_SELECTION(state))
13160 nk_textedit_move_to_last(state);
13162 state->
cursor = nk_textedit_move_to_word_next(state);
13163 nk_textedit_clamp(state );
13168 struct nk_text_find find;
13169 struct nk_text_edit_row row;
13170 int i, sel = shift_mod;
13179 nk_textedit_prep_selection_at_cursor(state);
13180 else if (NK_TEXT_HAS_SELECTION(state))
13181 nk_textedit_move_to_last(state);
13184 nk_textedit_clamp(state);
13193 int start = find.first_char + find.length;
13196 nk_textedit_layout_row(&row, state, state->
cursor, row_height, font);
13199 for (i=0; i < row.num_chars && x < row.x1; ++i) {
13200 float dx = nk_textedit_get_width(state, start, i, font);
13206 nk_textedit_clamp(state);
13216 struct nk_text_find find;
13217 struct nk_text_edit_row row;
13218 int i, sel = shift_mod;
13227 nk_textedit_prep_selection_at_cursor(state);
13228 else if (NK_TEXT_HAS_SELECTION(state))
13229 nk_textedit_move_to_first(state);
13232 nk_textedit_clamp(state);
13237 if (find.prev_first != find.first_char) {
13242 state->
cursor = find.prev_first;
13243 nk_textedit_layout_row(&row, state, state->
cursor, row_height, font);
13246 for (i=0; i < row.num_chars && x < row.x1; ++i) {
13247 float dx = nk_textedit_get_width(state, find.prev_first, i, font);
13253 nk_textedit_clamp(state);
13264 if (NK_TEXT_HAS_SELECTION(state))
13277 if (NK_TEXT_HAS_SELECTION(state))
13280 nk_textedit_clamp(state);
13281 if (state->
cursor > 0) {
13291 nk_textedit_prep_selection_at_cursor(state);
13302 nk_textedit_prep_selection_at_cursor(state);
13314 struct nk_text_find find;
13315 nk_textedit_clamp(state);
13316 nk_textedit_prep_selection_at_cursor(state);
13324 struct nk_text_find find;
13327 nk_textedit_clamp(state);
13328 nk_textedit_move_to_first(state);
13331 state->
cursor = find.first_char;
13338 struct nk_text_find find;
13339 nk_textedit_clamp(state);
13340 nk_textedit_prep_selection_at_cursor(state);
13344 state->
cursor = find.first_char + find.length;
13349 struct nk_text_find find;
13350 nk_textedit_clamp(state);
13351 nk_textedit_move_to_first(state);
13356 state->
cursor = find.first_char + find.length;
13430 nk_textedit_flush_redo(state);
13435 nk_textedit_discard_undo(state);
13448 nk_textedit_discard_undo(state);
13454 int insert_len,
int delete_len)
13464 if (insert_len == 0) {
13489 r->
where = u.where;
13491 if (u.delete_length)
13510 nk_textedit_discard_redo(s);
13521 for (i=0; i < u.delete_length; ++i)
13530 if (u.insert_length) {
13533 &s->
undo_char[u.char_storage], u.insert_length);
13536 state->
cursor = (short)(u.where + u.insert_length);
13595 nk_textedit_createundo(&state->
undo, where, 0, length);
13602 nk_rune *p = nk_textedit_createundo(&state->
undo, where, length, 0);
13604 for (i=0; i < length; ++i)
13610 nk_textedit_makeundo_replace(
struct nk_text_edit *state,
int where,
13611 int old_length,
int new_length)
13614 nk_rune *p = nk_textedit_createundo(&state->
undo, where, old_length, new_length);
13616 for (i=0; i < old_length; ++i)
13647 if (!state || !memory || !size)
return;
13657 if (!state || !alloc)
return;
13662 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
13667 if (!state)
return;
13669 nk_str_init_default(&state->
string);
13685 if (!state)
return;
13694 #define nk_widget_state_reset(s)\
13695 if ((*(s)) & NK_WIDGET_STATE_MODIFIED)\
13696 (*(s)) = NK_WIDGET_STATE_INACTIVE|NK_WIDGET_STATE_MODIFIED;\
13697 else (*(s)) = NK_WIDGET_STATE_INACTIVE;
13707 const char *
string,
int len,
const struct nk_text *t,
13715 if (!o || !t)
return;
13717 b.
h =
NK_MAX(b.
h, 2 * t->padding.y);
13718 label.x = 0; label.w = 0;
13719 label.y = b.
y + t->padding.y;
13723 text_width += (2.0f * t->padding.x);
13727 label.x = b.
x + t->padding.x;
13728 label.w =
NK_MAX(0, b.
w - 2 * t->padding.x);
13730 label.w =
NK_MAX(1, 2 * t->padding.x + (
float)text_width);
13731 label.x = (b.
x + t->padding.x + ((b.
w - 2 * t->padding.x) - label.w) / 2);
13732 label.x =
NK_MAX(b.
x + t->padding.x, label.x);
13733 label.w =
NK_MIN(b.
x + b.
w, label.x + label.w);
13734 if (label.w >= label.x) label.w -= label.x;
13736 label.x =
NK_MAX(b.
x + t->padding.x, (b.
x + b.
w) - (2 * t->padding.x + (
float)text_width));
13737 label.w = (float)text_width + 2 * t->padding.x;
13742 label.y = b.
y + b.
h/2.0f - (float)f->
height/2.0f;
13749 len, f, t->background, t->text);
13754 const char *
string,
int len,
const struct nk_text *t,
13767 if (!o || !t)
return;
13770 text.background = t->background;
13771 text.text = t->text;
13773 b.
w =
NK_MAX(b.
w, 2 * t->padding.x);
13774 b.
h =
NK_MAX(b.
h, 2 * t->padding.y);
13775 b.
h = b.
h - 2 * t->padding.y;
13777 line.x = b.
x + t->padding.x;
13778 line.y = b.
y + t->padding.y;
13779 line.w = b.
w - 2 * t->padding.x;
13780 line.h = 2 * t->padding.y + f->
height;
13782 fitting = nk_text_clamp(f,
string, len, line.w, &glyphs, &width, seperator,
NK_LEN(seperator));
13783 while (done < len) {
13784 if (!fitting || line.y + line.h >= (b.
y + b.
h))
break;
13785 nk_widget_text(o, line, &
string[done], fitting, &text,
NK_TEXT_LEFT, f);
13787 line.y += f->
height + 2 * t->padding.y;
13788 fitting = nk_text_clamp(f, &
string[done], len - done, line.w, &glyphs, &width, seperator,
NK_LEN(seperator));
13813 text.background = background;
13814 text.text = foreground;
13825 nk_fill_rect(out, nk_shrink_rect(content, border_width), 0, background);
13843 points[2].x, points[2].y, foreground);
13856 nk_widget_state_reset(state);
13865 #ifdef NK_BUTTON_TRIGGER_ON_RELEASE
13881 const struct nk_rect *bounds, nk_flags state,
13886 background = &style->
hover;
13888 background = &style->
active;
13889 else background = &style->
normal;
13909 if (!out || !style)
13928 const struct nk_rect *bounds,
const struct nk_rect *content, nk_flags state,
13930 nk_flags text_alignment,
const struct nk_user_font *font)
13934 background = nk_draw_button(out, bounds, state, style);
13938 text.background = background->
data.
color;
13940 if (state & NK_WIDGET_STATE_HOVER)
13942 else if (state & NK_WIDGET_STATE_ACTIVED)
13947 nk_widget_text(out, *content, txt, len, &text, text_alignment, font);
13951 nk_do_button_text(nk_flags *state,
13965 if (!out || !style || !font || !
string)
13968 ret = nk_do_button(state, out, bounds, style, in, behavior, &content);
13970 nk_draw_button_text(out, &bounds, &content, *state, style,
string, len, align, font);
13985 background = nk_draw_button(out, bounds, state, style);
13990 if (state & NK_WIDGET_STATE_HOVER)
13992 else if (state & NK_WIDGET_STATE_ACTIVED)
13995 nk_draw_symbol(out, type, *content, bg, sym, 1, font);
13999 nk_do_button_symbol(nk_flags *state,
14012 if (!out || !style || !font || !state)
14015 ret = nk_do_button(state, out, bounds, style, in, behavior, &content);
14017 nk_draw_button_symbol(out, &bounds, &content, *state, style, symbol, font);
14027 nk_draw_button(out, bounds, state, style);
14032 nk_do_button_image(nk_flags *state,
14043 if (!out || !style || !state)
14046 ret = nk_do_button(state, out, bounds, style, in, b, &content);
14053 nk_draw_button_image(out, &bounds, &content, *state, style, &img);
14070 background = nk_draw_button(out, bounds, state, style);
14072 text.background = background->
data.
color;
14076 if (state & NK_WIDGET_STATE_HOVER) {
14079 }
else if (state & NK_WIDGET_STATE_ACTIVED) {
14088 nk_draw_symbol(out, type, *symbol, style->
text_background, sym, 0, font);
14093 nk_do_button_text_symbol(nk_flags *state,
14095 enum nk_symbol_type symbol,
const char *str,
int len, nk_flags align,
14100 struct nk_rect tri = {0,0,0,0};
14106 if (!out || !style || !font)
14109 ret = nk_do_button(state, out, bounds, style, in, behavior, &content);
14110 tri.
y = content.
y + (content.
h/2) - font->
height/2;
14112 if (align & NK_TEXT_ALIGN_LEFT) {
14113 tri.
x = (content.
x + content.
w) - (2 * style->
padding.
x + tri.
w);
14115 }
else tri.
x = content.
x + 2 * style->
padding.
x;
14119 nk_draw_button_text_symbol(out, &bounds, &content, &tri,
14120 *state, style, str, len, symbol, font);
14129 const char *str,
int len,
const struct nk_user_font *font,
14134 background = nk_draw_button(out, bounds, state, style);
14138 text.background = background->
data.
color;
14140 if (state & NK_WIDGET_STATE_HOVER)
14142 else if (state & NK_WIDGET_STATE_ACTIVED)
14152 nk_do_button_text_image(nk_flags *state,
14154 struct nk_image img,
const char* str,
int len, nk_flags align,
14166 if (!out || !font || !style || !str)
14169 ret = nk_do_button(state, out, bounds, style, in, behavior, &content);
14171 icon.w = icon.h = bounds.
h - 2 * style->
padding.
y;
14172 if (align & NK_TEXT_ALIGN_LEFT) {
14173 icon.x = (bounds.
x + bounds.
w) - (2 * style->
padding.
x + icon.w);
14174 icon.x =
NK_MAX(icon.x, 0);
14175 }
else icon.x = bounds.
x + 2 * style->
padding.
x;
14183 nk_draw_button_text_image(out, &bounds, &content, &icon, *state, style, str, len, font, &img);
14193 enum nk_toggle_type {
14200 nk_flags *state,
int active)
14202 nk_widget_state_reset(state);
14218 const struct nk_rect *cursors,
const char *
string,
int len,
14226 if (state & NK_WIDGET_STATE_HOVER) {
14227 background = &style->
hover;
14230 }
else if (state & NK_WIDGET_STATE_ACTIVED) {
14231 background = &style->
hover;
14235 background = &style->
normal;
14251 text.padding.x = 0;
14252 text.padding.y = 0;
14254 nk_widget_text(out, *label,
string, len, &text,
NK_TEXT_LEFT, font);
14261 const struct nk_rect *cursors,
const char *
string,
int len,
14269 if (state & NK_WIDGET_STATE_HOVER) {
14270 background = &style->
hover;
14273 }
else if (state & NK_WIDGET_STATE_ACTIVED) {
14274 background = &style->
hover;
14278 background = &style->
normal;
14294 text.padding.x = 0;
14295 text.padding.y = 0;
14297 nk_widget_text(out, *label,
string, len, &text,
NK_TEXT_LEFT, font);
14301 nk_do_toggle(nk_flags *state,
14303 int *active,
const char *str,
int len,
enum nk_toggle_type type,
14316 if (!out || !style || !font || !active)
14330 select.
h = select.
w;
14331 select.
y = r.
y + r.
h/2.0f - select.
h/2.0f;
14341 label.
x = select.
x + select.
w + style->
spacing;
14342 label.
y = select.
y;
14344 label.
h = select.
w;
14347 was_active = *active;
14348 *active = nk_toggle_behavior(in, bounds, state, *active);
14353 if (type == NK_TOGGLE_CHECK) {
14354 nk_draw_checkbox(out, *state, style, *active, &label, &select, &cursor, str, len, font);
14356 nk_draw_option(out, *state, style, *active, &label, &select, &cursor, str, len, font);
14360 return (was_active != *active);
14372 const char *
string,
int len, nk_flags align,
const struct nk_user_font *font)
14376 text.padding = style->
padding;
14380 if (state & NK_WIDGET_STATE_ACTIVED) {
14381 background = &style->
pressed;
14383 }
else if (state & NK_WIDGET_STATE_HOVER) {
14384 background = &style->
hover;
14387 background = &style->
normal;
14391 if (state & NK_WIDGET_STATE_ACTIVED) {
14394 }
else if (state & NK_WIDGET_STATE_HOVER) {
14407 text.background =
nk_rgba(0,0,0,0);
14410 text.background = background->
data.
color;
14413 nk_widget_text(out, *bounds,
string, len, &text, align, font);
14418 struct nk_rect bounds,
const char *str,
int len, nk_flags align,
int *value,
14433 if (!state || !out || !str || !len || !value || !style || !font)
return 0;
14434 old_value = *
value;
14444 *value = !(*value);
14448 nk_draw_selectable(out, *state, style, *value, &bounds, 0,0, str, len, align, font);
14450 return old_value != *
value;
14455 struct nk_rect bounds,
const char *str,
int len, nk_flags align,
int *value,
14471 if (!state || !out || !str || !len || !value || !style || !font)
return 0;
14472 old_value = *
value;
14480 *value = !(*value);
14483 icon.
w = icon.
h = bounds.
h - 2 * style->
padding.
y;
14484 if (align & NK_TEXT_ALIGN_LEFT) {
14485 icon.
x = (bounds.
x + bounds.
w) - (2 * style->
padding.
x + icon.
w);
14487 }
else icon.
x = bounds.
x + 2 * style->
padding.
x;
14496 nk_draw_selectable(out, *state, style, *value, &bounds, &icon, img, str, len, align, font);
14498 return old_value != *
value;
14508 nk_slider_behavior(nk_flags *state,
struct nk_rect *logical_cursor,
14510 struct nk_rect bounds,
float slider_min,
float slider_max,
float slider_value,
14511 float slider_step,
float slider_steps)
14513 int left_mouse_down;
14514 int left_mouse_click_in_cursor;
14517 nk_widget_state_reset(state);
14522 if (left_mouse_down && left_mouse_click_in_cursor)
14525 const float d = in->
mouse.
pos.
x - (visual_cursor->
x+visual_cursor->
w*0.5f);
14526 const float pxstep = bounds.
w / slider_steps;
14530 if (
NK_ABS(d) >= pxstep) {
14531 const float steps = (float)((
int)(
NK_ABS(d) / pxstep));
14532 slider_value += (d > 0) ? (slider_step*steps) : -(slider_step*steps);
14533 slider_value =
NK_CLAMP(slider_min, slider_value, slider_max);
14534 ratio = (slider_value - slider_min)/slider_step;
14535 logical_cursor->
x = bounds.
x + (logical_cursor->
w * ratio);
14543 if (*state & NK_WIDGET_STATE_HOVER &&
14548 return slider_value;
14554 const struct nk_rect *visual_cursor,
float min,
float value,
float max)
14568 if (state & NK_WIDGET_STATE_ACTIVED) {
14569 background = &style->
active;
14572 }
else if (state & NK_WIDGET_STATE_HOVER) {
14573 background = &style->
hover;
14577 background = &style->
normal;
14584 bar.y = (visual_cursor->
y + visual_cursor->
h/2) - bounds->
h/12;
14586 bar.h = bounds->
h/6;
14589 fill.w = (visual_cursor->
x + (visual_cursor->
w/2.0f)) -
bar.x;
14613 nk_do_slider(nk_flags *state,
14615 float min,
float val,
float max,
float step,
14619 float slider_range;
14622 float slider_value;
14623 float slider_steps;
14624 float cursor_offset;
14626 struct nk_rect visual_cursor;
14627 struct nk_rect logical_cursor;
14631 if (!out || !style)
14646 button.
y = bounds.
y;
14647 button.w = bounds.
h;
14648 button.h = bounds.
h;
14651 button.x = bounds.
x;
14657 button.x = (bounds.
x + bounds.
w) - button.w;
14662 bounds.
x = bounds.
x + button.w + style->
spacing.
x;
14663 bounds.
w = bounds.
w - (2*button.w + 2*style->
spacing.
x);
14671 slider_max =
NK_MAX(min, max);
14672 slider_min =
NK_MIN(min, max);
14673 slider_value =
NK_CLAMP(slider_min, val, slider_max);
14674 slider_range = slider_max - slider_min;
14675 slider_steps = slider_range / step;
14676 cursor_offset = (slider_value - slider_min) / step;
14681 logical_cursor.
h = bounds.
h;
14682 logical_cursor.
w = bounds.
w / slider_steps;
14683 logical_cursor.
x = bounds.
x + (logical_cursor.
w * cursor_offset);
14684 logical_cursor.
y = bounds.
y;
14688 visual_cursor.
y = (bounds.
y + bounds.
h*0.5f) - visual_cursor.
h*0.5f;
14689 visual_cursor.
x = logical_cursor.
x - visual_cursor.
w*0.5f;
14691 slider_value = nk_slider_behavior(state, &logical_cursor, &visual_cursor,
14692 in, bounds, slider_min, slider_max, slider_value, step, slider_steps);
14693 visual_cursor.
x = logical_cursor.
x - visual_cursor.
w*0.5f;
14697 nk_draw_slider(out, *state, style, &bounds, &visual_cursor, slider_min, slider_value, slider_max);
14699 return slider_value;
14708 nk_progress_behavior(nk_flags *state,
const struct nk_input *in,
14709 struct nk_rect r, nk_size max, nk_size value,
int modifiable)
14711 nk_widget_state_reset(state);
14717 if (left_mouse_down && left_mouse_click_in_cursor) {
14719 value = (nk_size)
NK_MAX(0,((
float)max * ratio));
14730 if (!max)
return value;
14731 value =
NK_MIN(value, max);
14738 const struct nk_rect *scursor, nk_size value, nk_size max)
14747 if (state & NK_WIDGET_STATE_ACTIVED) {
14748 background = &style->
active;
14750 }
else if (state & NK_WIDGET_STATE_HOVER){
14751 background = &style->
hover;
14754 background = &style->
normal;
14772 nk_do_progress(nk_flags *state,
14774 nk_size value, nk_size max,
int modifiable,
14778 nk_size prog_value;
14783 if (!out || !style)
return 0;
14789 prog_scale = (float)value / (
float)max;
14790 cursor.w = (bounds.
w - 2) * prog_scale;
14793 prog_value =
NK_MIN(value, max);
14794 prog_value = nk_progress_behavior(state, in, bounds, max, prog_value, modifiable);
14798 nk_draw_progress(out, *state, style, &bounds, &cursor, value, max);
14809 nk_scrollbar_behavior(nk_flags *state,
struct nk_input *in,
14810 int has_scrolling,
const struct nk_rect *scroll,
14812 const struct nk_rect *empty1,
float scroll_offset,
14816 int left_mouse_down;
14817 int left_mouse_click_in_cursor;
14818 float scroll_delta;
14820 nk_widget_state_reset(state);
14821 if (!in)
return scroll_offset;
14830 if (left_mouse_down && left_mouse_click_in_cursor) {
14832 float pixel, delta;
14837 delta = (pixel / scroll->
h) * target;
14838 scroll_offset =
NK_CLAMP(0, scroll_offset + delta, target - scroll->
h);
14839 cursor_y = scroll->
y + ((scroll_offset/target) * scroll->
h);
14844 delta = (pixel / scroll->
w) * target;
14845 scroll_offset =
NK_CLAMP(0, scroll_offset + delta, target - scroll->
w);
14846 cursor_x = scroll->
x + ((scroll_offset/target) * scroll->
w);
14853 scroll_offset =
NK_MAX(0, scroll_offset - scroll->
h);
14854 else scroll_offset =
NK_MAX(0, scroll_offset - scroll->
w);
14859 scroll_offset =
NK_MIN(scroll_offset + scroll->
h, target - scroll->
h);
14860 else scroll_offset =
NK_MIN(scroll_offset + scroll->
w, target - scroll->
w);
14861 }
else if (has_scrolling) {
14862 if ((scroll_delta < 0 || (scroll_delta > 0))) {
14864 scroll_offset = scroll_offset + scroll_step * (-scroll_delta);
14866 scroll_offset =
NK_CLAMP(0, scroll_offset, target - scroll->
h);
14867 else scroll_offset =
NK_CLAMP(0, scroll_offset, target - scroll->
w);
14873 if (o ==
NK_VERTICAL) scroll_offset = target - scroll->
h;
14880 return scroll_offset;
14886 const struct nk_rect *scroll)
14892 if (state & NK_WIDGET_STATE_ACTIVED) {
14893 background = &style->
active;
14895 }
else if (state & NK_WIDGET_STATE_HOVER) {
14896 background = &style->
hover;
14899 background = &style->
normal;
14919 nk_do_scrollbarv(nk_flags *state,
14921 float offset,
float target,
float step,
float button_pixel_inc,
14930 float scroll_offset;
14932 float scroll_ratio;
14937 if (!out || !style)
return 0;
14941 if (target <= scroll.
h)
return 0;
14949 button.
x = scroll.
x;
14950 button.w = scroll.
w;
14951 button.h = scroll.
w;
14953 scroll_h =
NK_MAX(scroll.
h - 2 * button.h,0);
14954 scroll_step =
NK_MIN(step, button_pixel_inc);
14957 button.y = scroll.
y;
14958 if (nk_do_button_symbol(&ws, out, button, style->
dec_symbol,
14960 offset = offset - scroll_step;
14963 button.y = scroll.
y + scroll.
h - button.h;
14964 if (nk_do_button_symbol(&ws, out, button, style->
inc_symbol,
14966 offset = offset + scroll_step;
14968 scroll.
y = scroll.
y + button.h;
14969 scroll.
h = scroll_h;
14973 scroll_step =
NK_MIN(step, scroll.
h);
14974 scroll_offset =
NK_CLAMP(0, offset, target - scroll.
h);
14975 scroll_ratio = scroll.
h / target;
14976 scroll_off = scroll_offset / target;
14980 cursor.y = scroll.
y + (scroll_off * scroll.
h) + style->
border + style->
padding.
y;
14985 empty_north.x = scroll.
x;
14986 empty_north.y = scroll.
y;
14987 empty_north.w = scroll.
w;
14988 empty_north.h =
NK_MAX(cursor.y - scroll.
y, 0);
14990 empty_south.x = scroll.
x;
14991 empty_south.y = cursor.y + cursor.h;
14992 empty_south.w = scroll.
w;
14993 empty_south.h =
NK_MAX((scroll.
y + scroll.
h) - (cursor.y + cursor.h), 0);
14996 scroll_offset = nk_scrollbar_behavior(state, in, has_scrolling, &scroll, &cursor,
14997 &empty_north, &empty_south, scroll_offset, target, scroll_step,
NK_VERTICAL);
14998 scroll_off = scroll_offset / target;
15003 nk_draw_scrollbar(out, *state, style, &scroll, &cursor);
15005 return scroll_offset;
15009 nk_do_scrollbarh(nk_flags *state,
15011 float offset,
float target,
float step,
float button_pixel_inc,
15020 float scroll_offset;
15022 float scroll_ratio;
15026 if (!out || !style)
return 0;
15030 scroll.
w =
NK_MAX(scroll.
w, 2 * scroll.
h);
15031 if (target <= scroll.
w)
return 0;
15038 button.
y = scroll.
y;
15039 button.w = scroll.
h;
15040 button.h = scroll.
h;
15042 scroll_w = scroll.
w - 2 * button.w;
15043 scroll_step =
NK_MIN(step, button_pixel_inc);
15046 button.x = scroll.
x;
15047 if (nk_do_button_symbol(&ws, out, button, style->
dec_symbol,
15049 offset = offset - scroll_step;
15052 button.x = scroll.
x + scroll.
w - button.w;
15053 if (nk_do_button_symbol(&ws, out, button, style->
inc_symbol,
15055 offset = offset + scroll_step;
15057 scroll.
x = scroll.
x + button.w;
15058 scroll.
w = scroll_w;
15062 scroll_step =
NK_MIN(step, scroll.
w);
15063 scroll_offset =
NK_CLAMP(0, offset, target - scroll.
w);
15064 scroll_ratio = scroll.
w / target;
15065 scroll_off = scroll_offset / target;
15068 cursor.w = (scroll_ratio * scroll.
w) - (2*style->
border + 2*style->
padding.
x);
15069 cursor.x = scroll.
x + (scroll_off * scroll.
w) + style->
border + style->
padding.
x;
15074 empty_west.x = scroll.
x;
15075 empty_west.y = scroll.
y;
15076 empty_west.w = cursor.x - scroll.
x;
15077 empty_west.h = scroll.
h;
15079 empty_east.x = cursor.x + cursor.w;
15080 empty_east.y = scroll.
y;
15081 empty_east.w = (scroll.
x + scroll.
w) - (cursor.x + cursor.w);
15082 empty_east.h = scroll.
h;
15085 scroll_offset = nk_scrollbar_behavior(state, in, has_scrolling, &scroll, &cursor,
15086 &empty_west, &empty_east, scroll_offset, target, scroll_step,
NK_HORIZONTAL);
15087 scroll_off = scroll_offset / target;
15088 cursor.x = scroll.
x + (scroll_off * scroll.
w);
15092 nk_draw_scrollbar(out, *state, style, &scroll, &cursor);
15094 return scroll_offset;
15109 if (unicode > 128)
return nk_false;
15117 if ((unicode < '0' || unicode >
'9') && unicode !=
'.' && unicode !=
'-')
15126 if ((unicode < '0' || unicode >
'9') && unicode !=
'-')
15135 if ((unicode < '0' || unicode >
'9') &&
15136 (unicode < 'a' || unicode >
'f') &&
15137 (unicode < 'A' || unicode >
'F'))
15146 if (unicode < '0' || unicode >
'7')
15155 if (unicode !=
'0' && unicode !=
'1')
15167 const struct nk_style_edit *style,
float pos_x,
float pos_y,
15168 float x_offset,
const char *text,
int byte_len,
float row_height,
15170 struct nk_color foreground,
int is_selected)
15175 if (!text || !byte_len || !out || !style)
return;
15177 {
int glyph_len = 0;
15178 nk_rune unicode = 0;
15180 float line_width = 0;
15182 const char *line = text;
15183 float line_offset = 0;
15184 int line_count = 0;
15188 txt.background = background;
15189 txt.text = foreground;
15191 glyph_len =
nk_utf_decode(text+text_len, &unicode, byte_len-text_len);
15192 if (!glyph_len)
return;
15193 while ((text_len < byte_len) && glyph_len)
15195 if (unicode ==
'\n') {
15198 label.
y = pos_y + line_offset;
15199 label.
h = row_height;
15200 label.
w = line_width;
15203 label.
x += x_offset;
15207 nk_widget_text(out, label, line, (
int)((text + text_len) - line),
15213 line = text + text_len;
15214 line_offset += row_height;
15215 glyph_len =
nk_utf_decode(text + text_len, &unicode, (
int)(byte_len-text_len));
15218 if (unicode ==
'\r') {
15220 glyph_len =
nk_utf_decode(text + text_len, &unicode, byte_len-text_len);
15224 line_width += (float)glyph_width;
15225 text_len += glyph_len;
15226 glyph_len =
nk_utf_decode(text + text_len, &unicode, byte_len-text_len);
15229 if (line_width > 0) {
15232 label.
y = pos_y + line_offset;
15233 label.
h = row_height;
15234 label.
w = line_width;
15237 label.
x += x_offset;
15241 nk_widget_text(out, label, line, (
int)((text + text_len) - line),
15255 char prev_state = 0;
15256 char is_hovered = 0;
15257 char select_all = 0;
15258 char cursor_follow = 0;
15265 if (!state || !out || !style)
15278 old_clip = out->
clip;
15279 nk_unify(&clip, &old_clip, area.
x, area.y, area.x + area.w, area.y + area.h);
15282 prev_state = (char)edit->
active;
15286 bounds.
x, bounds.
y, bounds.
w, bounds.
h);
15290 if (!prev_state && edit->
active) {
15293 nk_textedit_clear_state(edit, type, filter);
15307 if (prev_state != edit->
active)
15323 nk_textedit_click(edit, mouse_x, mouse_y, font, row_height);
15326 nk_textedit_drag(edit, mouse_x, mouse_y, font, row_height);
15336 int old_mode = edit->
mode;
15340 nk_textedit_key(edit, (
enum nk_keys)i, shift_mod, font, row_height);
15344 if (old_mode != edit->
mode) {
15377 int begin =
NK_MIN(b, e);
15382 if (cut && !(flags & NK_EDIT_READ_ONLY)){
15390 if (paste && (flags & NK_EDIT_CLIPBOARD) && edit->
clip.
paste) {
15406 else nk_widget_state_reset(state);
15417 if (*state & NK_WIDGET_STATE_ACTIVED)
15418 background = &style->
active;
15419 else if (*state & NK_WIDGET_STATE_HOVER)
15420 background = &style->
hover;
15421 else background = &style->
normal;
15432 int total_lines = 1;
15436 const char *cursor_ptr = 0;
15437 const char *select_begin_ptr = 0;
15438 const char *select_end_ptr = 0;
15449 float line_width = 0.0f;
15455 nk_rune unicode = 0;
15465 while ((text_len < len) && glyph_len)
15468 if (!cursor_ptr && glyphs == edit->
cursor)
15473 const char *remaining;
15476 cursor_pos.
y = (float)(total_lines-1) * row_height;
15477 row_size = nk_text_calculate_text_bounds(font, text+row_begin,
15478 text_len-row_begin, row_height, &remaining,
15479 &out_offset, &glyph_offset, NK_STOP_ON_NEW_LINE);
15480 cursor_pos.
x = row_size.x;
15481 cursor_ptr = text + text_len;
15486 glyphs == selection_begin)
15491 const char *remaining;
15494 selection_offset_start.
y = (float)(
NK_MAX(total_lines-1,0)) * row_height;
15495 row_size = nk_text_calculate_text_bounds(font, text+row_begin,
15496 text_len-row_begin, row_height, &remaining,
15497 &out_offset, &glyph_offset, NK_STOP_ON_NEW_LINE);
15498 selection_offset_start.
x = row_size.x;
15499 select_begin_ptr = text + text_len;
15504 glyphs == selection_end)
15509 const char *remaining;
15512 selection_offset_end.
y = (float)(total_lines-1) * row_height;
15513 row_size = nk_text_calculate_text_bounds(font, text+row_begin,
15514 text_len-row_begin, row_height, &remaining,
15515 &out_offset, &glyph_offset, NK_STOP_ON_NEW_LINE);
15516 selection_offset_end.
x = row_size.x;
15517 select_end_ptr = text + text_len;
15519 if (unicode ==
'\n') {
15520 text_size.
x =
NK_MAX(text_size.
x, line_width);
15525 row_begin = text_len;
15526 glyph_len =
nk_utf_decode(text + text_len, &unicode, len-text_len);
15532 text_len += glyph_len;
15533 line_width += (float)glyph_width;
15535 glyph_len =
nk_utf_decode(text + text_len, &unicode, len-text_len);
15537 text+text_len, glyph_len);
15540 text_size.
y = (float)total_lines * row_height;
15544 cursor_pos.
x = line_width;
15545 cursor_pos.
y = text_size.
y - row_height;
15555 const float scroll_increment = area.w * 0.25f;
15562 if (flags & NK_EDIT_MULTILINE) {
15572 if (flags & NK_EDIT_MULTILINE)
15576 float scroll_target;
15577 float scroll_offset;
15586 scroll_step = scroll.
h * 0.10f;
15587 scroll_inc = scroll.
h * 0.01f;
15588 scroll_target = text_size.
y;
15589 edit->
scrollbar.
y = nk_do_scrollbarv(&ws, out, scroll, 0,
15590 scroll_offset, scroll_target, scroll_step, scroll_inc,
15596 {
struct nk_color background_color;
15598 struct nk_color sel_background_color;
15601 struct nk_color cursor_text_color;
15606 if (*state & NK_WIDGET_STATE_ACTIVED) {
15607 background = &style->
active;
15613 }
else if (*state & NK_WIDGET_STATE_HOVER) {
15614 background = &style->
hover;
15621 background = &style->
normal;
15629 background_color =
nk_rgba(0,0,0,0);
15630 else background_color = background->
data.
color;
15637 nk_edit_draw_text(out, style, area.x - edit->
scrollbar.
x,
15638 area.y - edit->
scrollbar.
y, 0, begin, l, row_height, font,
15639 background_color, text_color,
nk_false);
15645 NK_ASSERT(select_begin_ptr);
15646 nk_edit_draw_text(out, style, area.x - edit->
scrollbar.
x,
15647 area.y - edit->
scrollbar.
y, 0, begin, (
int)(select_begin_ptr - begin),
15648 row_height, font, background_color, text_color,
nk_false);
15652 NK_ASSERT(select_begin_ptr);
15653 if (!select_end_ptr) {
15657 nk_edit_draw_text(out, style,
15659 area.y + selection_offset_start.
y - edit->
scrollbar.
y,
15660 selection_offset_start.
x,
15661 select_begin_ptr, (
int)(select_end_ptr - select_begin_ptr),
15662 row_height, font, sel_background_color, sel_text_color,
nk_true);
15665 selection_end < edit->
string.len))
15668 const char *begin = select_end_ptr;
15671 NK_ASSERT(select_end_ptr);
15672 nk_edit_draw_text(out, style,
15674 area.y + selection_offset_end.
y - edit->
scrollbar.
y,
15675 selection_offset_end.
x,
15676 begin, (
int)(end - begin), row_height, font,
15677 background_color, text_color,
nk_true);
15685 (cursor_ptr && *cursor_ptr ==
'\n')) {
15689 cursor.h = font->
height;
15690 cursor.x = area.x + cursor_pos.
x - edit->
scrollbar.
x;
15691 cursor.y = area.y + cursor_pos.
y + row_height/2.0f - cursor.h/2.0f;
15701 NK_ASSERT(cursor_ptr);
15707 label.
h = row_height;
15710 txt.background = cursor_color;;
15711 txt.text = cursor_text_color;
15713 nk_widget_text(out, label, cursor_ptr, glyph_len, &txt,
NK_TEXT_LEFT, font);
15725 if (*state & NK_WIDGET_STATE_ACTIVED) {
15726 background = &style->
active;
15728 }
else if (*state & NK_WIDGET_STATE_HOVER) {
15729 background = &style->
hover;
15732 background = &style->
normal;
15736 background_color =
nk_rgba(0,0,0,0);
15737 else background_color = background->
data.
color;
15738 nk_edit_draw_text(out, style, area.x - edit->
scrollbar.
x,
15739 area.y - edit->
scrollbar.
y, 0, begin, l, row_height, font,
15740 background_color, text_color,
nk_false);
15751 enum nk_property_status {
15752 NK_PROPERTY_DEFAULT,
15756 enum nk_property_filter {
15760 enum nk_property_kind {
15765 union nk_property {
15770 struct nk_property_variant {
15771 enum nk_property_kind kind;
15772 union nk_property value;
15773 union nk_property min_value;
15774 union nk_property max_value;
15775 union nk_property step;
15779 nk_drag_behavior(nk_flags *state,
const struct nk_input *in,
15780 struct nk_rect drag,
struct nk_property_variant *variant,
15781 float inc_per_pixel)
15784 int left_mouse_click_in_cursor = in &&
15787 nk_widget_state_reset(state);
15791 if (left_mouse_down && left_mouse_click_in_cursor) {
15792 float delta, pixels;
15794 delta = pixels * inc_per_pixel;
15795 switch (variant->kind) {
15797 case NK_PROPERTY_INT:
15798 variant->value.i = variant->value.i + (
int)delta;
15799 variant->value.i =
NK_CLAMP(variant->min_value.i, variant->value.i, variant->max_value.i);
15801 case NK_PROPERTY_FLOAT:
15802 variant->value.f = variant->value.f + (float)delta;
15803 variant->value.f =
NK_CLAMP(variant->min_value.f, variant->value.f, variant->max_value.f);
15805 case NK_PROPERTY_DOUBLE:
15806 variant->value.d = variant->value.d + (double)delta;
15807 variant->value.d =
NK_CLAMP(variant->min_value.d, variant->value.d, variant->max_value.d);
15819 nk_property_behavior(nk_flags *ws,
const struct nk_input *in,
15821 struct nk_rect empty,
int *state,
struct nk_property_variant *variant,
15822 float inc_per_pixel)
15824 if (in && *state == NK_PROPERTY_DEFAULT) {
15826 *state = NK_PROPERTY_EDIT;
15828 *state = NK_PROPERTY_DRAG;
15830 *state = NK_PROPERTY_DRAG;
15832 if (*state == NK_PROPERTY_DRAG) {
15833 nk_drag_behavior(ws, in, property, variant, inc_per_pixel);
15834 if (!(*ws & NK_WIDGET_STATE_ACTIVED)) *state = NK_PROPERTY_DEFAULT;
15840 const struct nk_rect *bounds,
const struct nk_rect *label, nk_flags state,
15841 const char *name,
int len,
const struct nk_user_font *font)
15847 if (state & NK_WIDGET_STATE_ACTIVED) {
15848 background = &style->
active;
15850 }
else if (state & NK_WIDGET_STATE_HOVER) {
15851 background = &style->
hover;
15854 background = &style->
normal;
15861 text.background =
nk_rgba(0,0,0,0);
15863 text.background = background->
data.
color;
15874 nk_do_property(nk_flags *ws,
15876 const char *name,
struct nk_property_variant *variant,
15877 float inc_per_pixel,
char *buffer,
int *len,
15878 int *state,
int *cursor,
int *select_begin,
int *select_end,
15880 enum nk_property_filter filter,
struct nk_input *in,
15889 int num_len, name_len;
15906 left.y =
property.y + style->
border +
property.h/2.0f - left.h/2;
15911 label.
x = left.x + left.w + style->
padding.
x;
15912 label.
w = (float)size + 2 * style->
padding.
x;
15920 right.x =
property.x +
property.w - (right.w + style->
padding.
x);
15923 if (*state == NK_PROPERTY_EDIT) {
15929 switch (variant->kind) {
15931 case NK_PROPERTY_INT:
15932 nk_itoa(
string, variant->value.i);
15935 case NK_PROPERTY_FLOAT:
15936 nk_dtoa(
string, (
double)variant->value.f);
15939 case NK_PROPERTY_DOUBLE:
15940 nk_dtoa(
string, variant->value.d);
15949 edit.
w = (float)size + 2 * style->
padding.
x;
15950 edit.
w =
NK_MIN(edit.
w, right.x - (label.
x + label.
w));
15951 edit.
x = right.x - (edit.
w + style->
padding.
x);
15952 edit.
y =
property.y + style->
border;
15953 edit.
h =
property.h - (2 * style->
border);
15956 empty.
w = edit.
x - (label.
x + label.
w);
15957 empty.
x = label.
x + label.
w;
15958 empty.
y =
property.y;
15959 empty.
h =
property.h;
15962 old = (*state == NK_PROPERTY_EDIT);
15963 nk_property_behavior(ws, in, property, label, edit, empty, state, variant, inc_per_pixel);
15967 nk_draw_property(out, style, &property, &label, *ws, name, name_len, font);
15971 if (nk_do_button_symbol(ws, out, left, style->
sym_left, behavior, &style->
dec_button, in, font)) {
15972 switch (variant->kind) {
15974 case NK_PROPERTY_INT:
15975 variant->value.i =
NK_CLAMP(variant->min_value.i, variant->value.i - variant->step.i, variant->max_value.i);
break;
15976 case NK_PROPERTY_FLOAT:
15977 variant->value.f =
NK_CLAMP(variant->min_value.f, variant->value.f - variant->step.f, variant->max_value.f);
break;
15978 case NK_PROPERTY_DOUBLE:
15979 variant->value.d =
NK_CLAMP(variant->min_value.d, variant->value.d - variant->step.d, variant->max_value.d);
break;
15984 if (nk_do_button_symbol(ws, out, right, style->
sym_right, behavior, &style->
inc_button, in, font)) {
15985 switch (variant->kind) {
15987 case NK_PROPERTY_INT:
15988 variant->value.i =
NK_CLAMP(variant->min_value.i, variant->value.i + variant->step.i, variant->max_value.i);
break;
15989 case NK_PROPERTY_FLOAT:
15990 variant->value.f =
NK_CLAMP(variant->min_value.f, variant->value.f + variant->step.f, variant->max_value.f);
break;
15991 case NK_PROPERTY_DOUBLE:
15992 variant->value.d =
NK_CLAMP(variant->min_value.d, variant->value.d + variant->step.d, variant->max_value.d);
break;
15996 if (old != NK_PROPERTY_EDIT && (*state == NK_PROPERTY_EDIT)) {
15998 NK_MEMCPY(buffer, dst, (nk_size)*length);
16004 }
else active = (*state == NK_PROPERTY_EDIT);
16008 text_edit->
active = (
unsigned char)active;
16018 nk_do_edit(ws, out, edit,
NK_EDIT_FIELD|NK_EDIT_AUTO_SELECT,
16019 filters[filter], text_edit, &style->
edit, (*state == NK_PROPERTY_EDIT) ? in: 0, font);
16022 active = text_edit->
active;
16023 *cursor = text_edit->
cursor;
16030 if (old && !active) {
16032 *state = NK_PROPERTY_DEFAULT;
16033 buffer[*len] =
'\0';
16034 switch (variant->kind) {
16036 case NK_PROPERTY_INT:
16037 variant->value.i =
nk_strtoi(buffer, 0);
16038 variant->value.i =
NK_CLAMP(variant->min_value.i, variant->value.i, variant->max_value.i);
16040 case NK_PROPERTY_FLOAT:
16042 variant->value.f =
nk_strtof(buffer, 0);
16043 variant->value.f =
NK_CLAMP(variant->min_value.f, variant->value.f, variant->max_value.f);
16045 case NK_PROPERTY_DOUBLE:
16047 variant->value.d =
nk_strtod(buffer, 0);
16048 variant->value.d =
NK_CLAMP(variant->min_value.d, variant->value.d, variant->max_value.d);
16059 nk_color_picker_behavior(nk_flags *state,
16065 int value_changed = 0;
16066 int hsv_changed = 0;
16070 NK_ASSERT(hue_bar);
16078 value_changed = hsv_changed = 1;
16084 value_changed = hsv_changed = 1;
16094 nk_widget_state_reset(state);
16099 if (value_changed) {
16100 color->
a = (
nk_byte)(hsva[3] * 255.0f);
16111 return value_changed;
16123 const float crosshair_size = 7.0f;
16131 NK_ASSERT(hue_bar);
16135 for (i = 0; i < 6; ++i) {
16142 {255, 0, 255, 255},
16146 nk_rect(hue_bar->
x, hue_bar->
y + (
float)i * (hue_bar->
h/6.0f) + 0.5f,
16147 hue_bar->
w, (hue_bar->
h/6.0f) + 0.5f), hue_colors[i], hue_colors[i],
16148 hue_colors[i+1], hue_colors[i+1]);
16150 line_y = (float)(
int)(hue_bar->
y + hsva[0] * matrix->
h + 0.5f);
16152 line_y, 1,
nk_rgb(255,255,255));
16157 line_y = (float)(
int)(alpha_bar->
y + (1.0f - alpha) * matrix->
h + 0.5f);
16161 line_y, 1,
nk_rgb(255,255,255));
16165 temp =
nk_hsv_f(hsva[0], 1.0f, 1.0f);
16170 {
struct nk_vec2 p;
float S = hsva[1];
float V = hsva[2];
16171 p.
x = (float)(
int)(matrix->
x + S * matrix->
w);
16172 p.y = (float)(
int)(matrix->
y + (1.0f - V) * matrix->
h);
16173 nk_stroke_line(o, p.x - crosshair_size, p.y, p.x-2, p.y, 1.0f, white);
16174 nk_stroke_line(o, p.x + crosshair_size + 1, p.y, p.x+3, p.y, 1.0f, white);
16175 nk_stroke_line(o, p.x, p.y + crosshair_size + 1, p.x, p.y+3, 1.0f, white);
16176 nk_stroke_line(o, p.x, p.y - crosshair_size, p.x, p.y-2, 1.0f, white);}
16180 nk_do_color_picker(nk_flags *state,
16196 if (!out || !color || !state || !font)
16200 bounds.
x += padding.
x;
16201 bounds.
y += padding.
x;
16202 bounds.
w -= 2 * padding.
x;
16203 bounds.
h -= 2 * padding.
y;
16205 matrix.
x = bounds.
x;
16206 matrix.
y = bounds.
y;
16207 matrix.
h = bounds.
h;
16208 matrix.
w = bounds.
w - (3 * padding.
x + 2 * bar_w);
16211 hue_bar.
y = bounds.
y;
16212 hue_bar.
h = matrix.
h;
16213 hue_bar.
x = matrix.
x + matrix.
w + padding.
x;
16215 alpha_bar.
x = hue_bar.
x + hue_bar.
w + padding.
x;
16216 alpha_bar.
y = bounds.
y;
16217 alpha_bar.
w = bar_w;
16218 alpha_bar.
h = matrix.
h;
16220 ret = nk_color_picker_behavior(state, &bounds, &matrix, &hue_bar,
16221 (fmt ==
NK_RGBA) ? &alpha_bar:0, color, in);
16222 nk_draw_color_picker(out, &matrix, &hue_bar, (fmt ==
NK_RGBA) ? &alpha_bar:0, *color);
16232 #define NK_COLOR_MAP(NK_COLOR)\
16233 NK_COLOR(NK_COLOR_TEXT, 175,175,175,255) \
16234 NK_COLOR(NK_COLOR_WINDOW, 45, 45, 45, 255) \
16235 NK_COLOR(NK_COLOR_HEADER, 40, 40, 40, 255) \
16236 NK_COLOR(NK_COLOR_BORDER, 65, 65, 65, 255) \
16237 NK_COLOR(NK_COLOR_BUTTON, 50, 50, 50, 255) \
16238 NK_COLOR(NK_COLOR_BUTTON_HOVER, 40, 40, 40, 255) \
16239 NK_COLOR(NK_COLOR_BUTTON_ACTIVE, 35, 35, 35, 255) \
16240 NK_COLOR(NK_COLOR_TOGGLE, 100,100,100,255) \
16241 NK_COLOR(NK_COLOR_TOGGLE_HOVER, 120,120,120,255) \
16242 NK_COLOR(NK_COLOR_TOGGLE_CURSOR, 45, 45, 45, 255) \
16243 NK_COLOR(NK_COLOR_SELECT, 45, 45, 45, 255) \
16244 NK_COLOR(NK_COLOR_SELECT_ACTIVE, 35, 35, 35,255) \
16245 NK_COLOR(NK_COLOR_SLIDER, 38, 38, 38, 255) \
16246 NK_COLOR(NK_COLOR_SLIDER_CURSOR, 100,100,100,255) \
16247 NK_COLOR(NK_COLOR_SLIDER_CURSOR_HOVER, 120,120,120,255) \
16248 NK_COLOR(NK_COLOR_SLIDER_CURSOR_ACTIVE, 150,150,150,255) \
16249 NK_COLOR(NK_COLOR_PROPERTY, 38, 38, 38, 255) \
16250 NK_COLOR(NK_COLOR_EDIT, 38, 38, 38, 255) \
16251 NK_COLOR(NK_COLOR_EDIT_CURSOR, 175,175,175,255) \
16252 NK_COLOR(NK_COLOR_COMBO, 45, 45, 45, 255) \
16253 NK_COLOR(NK_COLOR_CHART, 120,120,120,255) \
16254 NK_COLOR(NK_COLOR_CHART_COLOR, 45, 45, 45, 255) \
16255 NK_COLOR(NK_COLOR_CHART_COLOR_HIGHLIGHT,255, 0, 0, 255) \
16256 NK_COLOR(NK_COLOR_SCROLLBAR, 40, 40, 40, 255) \
16257 NK_COLOR(NK_COLOR_SCROLLBAR_CURSOR, 100,100,100,255) \
16258 NK_COLOR(NK_COLOR_SCROLLBAR_CURSOR_HOVER,120,120,120,255) \
16259 NK_COLOR(NK_COLOR_SCROLLBAR_CURSOR_ACTIVE,150,150,150,255) \
16260 NK_COLOR(NK_COLOR_TAB_HEADER, 40, 40, 40,255)
16264 #define NK_COLOR(a,b,c,d,e) {b,c,d,e},
16265 NK_COLOR_MAP(NK_COLOR)
16270 #define NK_COLOR(a,b,c,d,e) #a,
16271 NK_COLOR_MAP(NK_COLOR)
16276 {
return nk_color_names[c];}
16307 style = &ctx->
style;
16308 table = (!table) ? nk_default_color_style: table;
16311 text = &style->
text;
16316 button = &style->
button;
16396 toggle = &style->
option;
16437 slider = &style->
slider;
16548 edit = &style->
edit;
16586 property->padding =
nk_vec2(4,4);
16587 property->border = 1;
16588 property->rounding = 10;
16589 property->draw_begin = 0;
16590 property->draw_end = 0;
16637 chart = &style->
chart;
16648 combo = &style->
combo;
16836 style = &ctx->
style;
16844 struct nk_config_stack_user_font *font_stack;
16845 struct nk_config_stack_user_font_element *element;
16848 if (!ctx)
return 0;
16851 NK_ASSERT(font_stack->head < (
int)
NK_LEN(font_stack->elements));
16852 if (font_stack->head >= (
int)
NK_LEN(font_stack->elements))
16855 element = &font_stack->elements[font_stack->head++];
16865 struct nk_config_stack_user_font *font_stack;
16866 struct nk_config_stack_user_font_element *element;
16869 if (!ctx)
return 0;
16872 NK_ASSERT(font_stack->head > 0);
16873 if (font_stack->head < 1)
16876 element = &font_stack->elements[--font_stack->head];
16877 *element->address = element->old_value;
16881 #define NK_STYLE_PUSH_IMPLEMENATION(prefix, type, stack) \
16882 nk_style_push_##type(struct nk_context *ctx, prefix##_##type *address, prefix##_##type value)\
16884 struct nk_config_stack_##type * type_stack;\
16885 struct nk_config_stack_##type##_element *element;\
16887 if (!ctx) return 0;\
16888 type_stack = &ctx->stacks.stack;\
16889 NK_ASSERT(type_stack->head < (int)NK_LEN(type_stack->elements));\
16890 if (type_stack->head >= (int)NK_LEN(type_stack->elements))\
16892 element = &type_stack->elements[type_stack->head++];\
16893 element->address = address;\
16894 element->old_value = *address;\
16899 #define NK_STYLE_POP_IMPLEMENATION(type, stack) \
16900 nk_style_pop_##type(struct nk_context *ctx)\
16902 struct nk_config_stack_##type *type_stack;\
16903 struct nk_config_stack_##type##_element *element;\
16905 if (!ctx) return 0;\
16906 type_stack = &ctx->stacks.stack;\
16907 NK_ASSERT(type_stack->head > 0);\
16908 if (type_stack->head < 1)\
16910 element = &type_stack->elements[--type_stack->head];\
16911 *element->address = element->old_value;\
16915 NK_API int NK_STYLE_PUSH_IMPLEMENATION(
struct nk, style_item, style_items)
16916 NK_API int NK_STYLE_PUSH_IMPLEMENATION(nk,
float, floats)
16917 NK_API int NK_STYLE_PUSH_IMPLEMENATION(struct nk, vec2, vectors)
16918 NK_API int NK_STYLE_PUSH_IMPLEMENATION(nk,flags, flags)
16919 NK_API int NK_STYLE_PUSH_IMPLEMENATION(struct nk,color, colors)
16921 NK_API int NK_STYLE_POP_IMPLEMENATION(style_item, style_items)
16922 NK_API int NK_STYLE_POP_IMPLEMENATION(
float,floats)
16923 NK_API int NK_STYLE_POP_IMPLEMENATION(vec2, vectors)
16924 NK_API int NK_STYLE_POP_IMPLEMENATION(flags,flags)
16925 NK_API int NK_STYLE_POP_IMPLEMENATION(color,colors)
16932 if (!ctx)
return 0;
16933 style = &ctx->style;
16960 style = &ctx->
style;
16971 style = &ctx->
style;
16973 style->
cursors[i] = &cursors[i];
16984 unsigned int capacity)
16986 nk_zero(pool,
sizeof(*pool));
16987 pool->
alloc = *alloc;
16994 nk_pool_free(
struct nk_pool *pool)
17007 nk_pool_init_fixed(
struct nk_pool *pool,
void *memory, nk_size size)
17009 nk_zero(pool,
sizeof(*pool));
17010 NK_ASSERT(size >=
sizeof(
struct nk_page));
17011 if (size <
sizeof(
struct nk_page))
return;
17019 nk_pool_alloc(
struct nk_pool *pool)
17025 if (!pool->
pages) {
17026 NK_ASSERT(pool->
pages);
17032 nk_size size =
sizeof(
struct nk_page);
17033 size += NK_POOL_DEFAULT_CAPACITY *
sizeof(
union nk_page_data);
17035 page->next = pool->
pages;
17036 pool->
pages = page;
17065 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
17066 nk_draw_list_init(&ctx->draw_list);
17070 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
17076 alloc.
alloc = nk_malloc;
17077 alloc.
free = nk_mfree;
17078 return nk_init(ctx, &alloc, font);
17087 if (!memory)
return 0;
17088 nk_setup(ctx, font);
17100 if (!cmds || !pool)
return 0;
17102 nk_setup(ctx, font);
17110 nk_pool_init(&ctx->
pool, alloc, NK_POOL_DEFAULT_CAPACITY);
17121 if (!alloc)
return 0;
17122 nk_setup(ctx, font);
17124 nk_pool_init(&ctx->
pool, alloc, NK_POOL_DEFAULT_CAPACITY);
17129 #ifdef NK_INCLUDE_COMMAND_USERDATA
17131 nk_set_user_data(
struct nk_context *ctx, nk_handle handle)
17134 ctx->userdata = handle;
17147 nk_pool_free(&ctx->
pool);
17180 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
17181 nk_draw_list_clear(&ctx->draw_list);
17202 nk_free_window(ctx, iter->
popup.
win);
17210 if (it->
seq != ctx->
seq) {
17211 nk_remove_table(iter, it);
17213 nk_free_table(ctx, it);
17223 nk_remove_window(ctx, iter);
17224 nk_free_window(ctx, iter);
17226 }
else iter = iter->
next;
17241 if (!ctx || !buffer)
return;
17245 buffer->
clip = nk_null_rect;
17253 nk_start_buffer(ctx, &win->
buffer);
17262 if (!ctx || !win)
return;
17279 if (!ctx || !win)
return;
17291 if (!ctx || !buffer)
return;
17304 if (!ctx || !win)
return;
17305 nk_finish_buffer(ctx, &win->
buffer);
17311 parent_last->
next = buf->
end;
17319 nk_byte *buffer = 0;
17328 nk_start_buffer(ctx, &ctx->
overlay);
17332 mouse_bounds.w = cursor->size.x;
17333 mouse_bounds.h = cursor->size.y;
17336 nk_finish_buffer(ctx, &ctx->
overlay);
17341 while (iter != 0) {
17356 while (iter != 0) {
17382 if (!ctx)
return 0;
17383 if (!ctx->
count)
return 0;
17394 if (!iter)
return 0;
17404 if (!ctx || !cmd || !ctx->
count)
return 0;
17417 nk_panel_has_header(nk_flags flags,
const char *title)
17442 nk_panel_get_border(
const struct nk_style *style, nk_flags flags,
17468 case NK_PANEL_MENU:
return style->window.menu_border_color;
17495 struct nk_vec2 scrollbar_size;
17496 struct nk_vec2 panel_padding;
17509 style = &ctx->
style;
17510 font = style->
font;
17515 #ifdef NK_INCLUDE_COMMAND_USERDATA
17520 panel_padding = nk_panel_get_padding(style, panel_type);
17524 int left_mouse_down;
17525 int left_mouse_click_in_cursor;
17532 if (nk_panel_has_header(win->
flags, title)) {
17535 }
else header.h = panel_padding.y;
17541 if (left_mouse_down && left_mouse_click_in_cursor) {
17551 layout->
type = panel_type;
17554 layout->
bounds.
x += panel_padding.x;
17555 layout->
bounds.
w -= 2*panel_padding.x;
17556 if (win->
flags & NK_WINDOW_BORDER) {
17557 layout->
border = nk_panel_get_border(style, win->
flags, panel_type);
17559 }
else layout->
border = 0;
17573 layout->
bounds.
w -= scrollbar_size.x;
17574 if (!nk_panel_is_nonblock(panel_type)) {
17582 if (nk_panel_has_header(win->
flags, title))
17597 layout->
bounds.
y += header.h;
17598 layout->
bounds.
h -= header.h;
17599 layout->
at_y += header.h;
17602 if (ctx->
active == win) {
17616 text.background =
nk_rgba(0,0,0,0);
17619 text.background = background->
data.
color;
17627 button.w = button.h;
17638 if (nk_do_button_symbol(&ws, &win->
buffer, button,
17651 button.x = (header.w + header.x) - button.w;
17658 button.x = header.x;
17671 struct nk_rect label = {0,0,0,0};
17680 label.
w =
NK_CLAMP(0, label.
w, header.x + header.w - label.
x);
17681 nk_widget_text(out, label,(
const char*)title, text_len, &text,
NK_TEXT_LEFT, font);}
17702 layout->
clip = clip;}
17715 struct nk_vec2 scrollbar_size;
17716 struct nk_vec2 panel_padding;
17725 layout = window->
layout;
17726 style = &ctx->
style;
17729 if (!nk_panel_is_sub(layout->
type))
17734 panel_padding = nk_panel_get_padding(style, layout->
type);
17748 empty_space.x = window->
bounds.
x;
17749 empty_space.y = layout->
bounds.
y;
17750 empty_space.h = panel_padding.y;
17751 empty_space.w = window->
bounds.
w;
17755 empty_space.x = window->
bounds.
x;
17756 empty_space.y = layout->
bounds.
y;
17757 empty_space.w = panel_padding.x + layout->
border;
17758 empty_space.h = layout->
bounds.
h;
17763 empty_space.y = layout->
bounds.
y;
17764 empty_space.w = panel_padding.x + layout->
border;
17765 empty_space.h = layout->
bounds.
h;
17767 empty_space.w += scrollbar_size.x;
17772 empty_space.x = window->
bounds.
x;
17774 empty_space.w = window->
bounds.
w;
17775 empty_space.h = scrollbar_size.y;
17786 int scroll_has_scrolling;
17787 float scroll_target;
17788 float scroll_offset;
17793 if (nk_panel_is_sub(layout->
type))
17796 struct nk_window *root_window = window;
17798 while (root_panel->
parent)
17799 root_panel = root_panel->
parent;
17800 while (root_window->
parent)
17801 root_window = root_window->
parent;
17804 scroll_has_scrolling = 0;
17812 root_panel = window->
layout;
17813 while (root_panel->
parent) {
17815 root_panel = root_panel->
parent;
17818 scroll_has_scrolling =
nk_true;
17821 }
else if (!nk_panel_is_sub(layout->
type)) {
17827 }
else scroll_has_scrolling =
nk_false;
17831 nk_flags state = 0;
17832 scroll.x = layout->
bounds.
x + layout->
bounds.
w + panel_padding.x;
17834 scroll.w = scrollbar_size.x;
17837 scroll_offset = (float)*layout->
offset_y;
17838 scroll_step = scroll.h * 0.10f;
17839 scroll_inc = scroll.h * 0.01f;
17840 scroll_target = (
float)(
int)(layout->
at_y - scroll.y);
17841 scroll_offset = nk_do_scrollbarv(&state, out, scroll, scroll_has_scrolling,
17842 scroll_offset, scroll_target, scroll_step, scroll_inc,
17845 if (in && scroll_has_scrolling)
17850 nk_flags state = 0;
17854 scroll.h = scrollbar_size.y;
17856 scroll_offset = (float)*layout->
offset_x;
17857 scroll_target = (
float)(
int)(layout->
max_x - scroll.x);
17858 scroll_step = layout->
max_x * 0.05f;
17859 scroll_inc = layout->
max_x * 0.005f;
17860 scroll_offset = nk_do_scrollbarh(&state, out, scroll, scroll_has_scrolling,
17861 scroll_offset, scroll_target, scroll_step, scroll_inc,
17872 if ((!has_input && is_window_hovered) || (!is_window_hovered && !any_item_active))
17878 if (layout->
flags & NK_WINDOW_BORDER)
17880 struct nk_color border_color = nk_panel_get_border_color(style, layout->
type);
17890 layout->
border, border_color);
17899 padding_y, layout->
border, border_color);
17904 padding_y, layout->
border, border_color);
17912 scaler.
w = scrollbar_size.x;
17913 scaler.h = scrollbar_size.y;
17916 scaler.x = layout->
bounds.
x - panel_padding.x * 0.5f;
17917 else scaler.x = layout->
bounds.
x + layout->
bounds.
w + panel_padding.x;
17919 scaler.x -= scaler.w;
17928 scaler.y + scaler.h, scaler.x + scaler.w,
17929 scaler.y + scaler.h, item->
data.
color);
17932 scaler.y + scaler.h, scaler.x, scaler.y + scaler.h, item->
data.
color);
17943 if (left_mouse_down && left_mouse_click_in_scaler) {
17946 delta_x = -delta_x;
17950 if (window->
bounds.
w + delta_x >= window_size.
x) {
17951 if ((delta_x < 0) || (delta_x > 0 && in->
mouse.
pos.
x >= scaler.x)) {
17971 if (!nk_panel_is_sub(layout->
type)) {
17974 nk_command_buffer_reset(&window->
buffer);
17976 else nk_finish(ctx, window);
17998 nk_zero(&window->
edit,
sizeof(window->
edit));
18024 nk_create_page_element(
struct nk_context *ctx)
18033 elem = nk_pool_alloc(&ctx->
pool);
18035 if (!elem)
return 0;
18042 if (!elem)
return 0;
18051 nk_link_page_element_into_freelist(
struct nk_context *ctx,
18068 nk_link_page_element_into_freelist(ctx, elem);
18072 {
void *elem_end = (
void*)(elem + 1);
18074 if (elem_end == buffer_end)
18076 else nk_link_page_element_into_freelist(ctx, elem);}
18088 elem = nk_create_page_element(ctx);
18089 if (!elem)
return 0;
18099 nk_free_page_element(ctx, pe);
18111 elem = nk_create_page_element(ctx);
18112 if (!elem)
return 0;
18122 nk_free_page_element(ctx, pe);
18159 nk_hash name, nk_uint value)
18163 if (!win || !ctx)
return 0;
18165 struct nk_table *tbl = nk_create_table(ctx);
18167 if (!tbl)
return 0;
18168 nk_push_table(win, tbl);
18177 nk_find_value(
struct nk_window *win, nk_hash name)
18183 for (i = 0; i < size; ++i) {
18184 if (iter->
keys[i] == name) {
18186 return &iter->
values[i];
18204 elem = nk_create_page_element(ctx);
18205 if (!elem)
return 0;
18216 nk_free_window(ctx, win->
popup.
win);
18225 nk_remove_table(win, it);
18226 nk_free_table(ctx, it);
18235 nk_free_page_element(ctx, pe);}
18239 nk_find_window(
struct nk_context *ctx, nk_hash hash,
const char *name)
18244 NK_ASSERT(iter != iter->
next);
18245 if (iter->
name == hash) {
18255 enum nk_window_insert_location {
18261 enum nk_window_insert_location loc)
18266 if (!win || !ctx)
return;
18270 NK_ASSERT(iter != iter->
next);
18271 NK_ASSERT(iter != win);
18272 if (iter == win)
return;
18284 if (loc == NK_INSERT_BACK) {
18308 if (win == ctx->
begin || win == ctx->
end) {
18309 if (win == ctx->
begin) {
18314 if (win == ctx->
end) {
18337 struct nk_rect bounds, nk_flags flags)
18344 struct nk_rect bounds, nk_flags flags)
18348 nk_hash title_hash;
18356 NK_ASSERT(!ctx->
current &&
"if this triggers you missed a `nk_end` call");
18357 if (!ctx || ctx->
current || !title || !name)
18361 style = &ctx->
style;
18364 win = nk_find_window(ctx, title_hash, name);
18368 win = (
struct nk_window*)nk_create_window(ctx);
18370 if (!win)
return 0;
18373 nk_insert_window(ctx, win, NK_INSERT_FRONT);
18374 else nk_insert_window(ctx, win, NK_INSERT_BACK);
18379 win->
name = title_hash;
18399 NK_ASSERT(win->
seq != ctx->
seq);
18413 int inpanel, ishovered;
18421 nk_start(ctx, win);
18431 iter_bounds.
x, iter_bounds.
y, iter_bounds.
w, iter_bounds.
h) &&
18445 if (iter && inpanel && (win != ctx->
end) && !(iter->
flags & NK_WINDOW_BACKGROUND)) {
18452 iter_bounds.
x, iter_bounds.
y, iter_bounds.
w, iter_bounds.
h) &&
18464 if (!iter && ctx->
end != win) {
18465 if (!(win->
flags & NK_WINDOW_BACKGROUND)) {
18468 nk_remove_window(ctx, win);
18469 nk_insert_window(ctx, win, NK_INSERT_BACK);
18474 if (ctx->
end != win && !(win->
flags & NK_WINDOW_BACKGROUND))
18491 NK_ASSERT(ctx->
current &&
"if this triggers you forgot to call `nk_begin`");
18537 if (!ctx || !ctx->
current)
return 0;
18546 if (!ctx || !ctx->
current)
return 0;
18596 if (!ctx || !ctx->
current)
return 0;
18605 if (!ctx || !ctx->
current)
return 0;
18615 if (!ctx || !ctx->
current)
return 0;
18624 if (!ctx || !ctx->
current)
return 0;
18633 if (!ctx)
return 0;
18658 return any_hovered || any_active;
18665 nk_hash title_hash;
18668 if (!ctx)
return 0;
18672 win = nk_find_window(ctx, title_hash, name);
18673 if (!win)
return 0;
18681 nk_hash title_hash;
18684 if (!ctx)
return 1;
18688 win = nk_find_window(ctx, title_hash, name);
18689 if (!win)
return 1;
18697 nk_hash title_hash;
18700 if (!ctx)
return 1;
18704 win = nk_find_window(ctx, title_hash, name);
18705 if (!win)
return 1;
18713 nk_hash title_hash;
18716 if (!ctx)
return 0;
18720 win = nk_find_window(ctx, title_hash, name);
18721 if (!win)
return 0;
18722 return win == ctx->
active;
18729 nk_hash title_hash;
18732 return nk_find_window(ctx, title_hash, name);
18743 NK_ASSERT(ctx->
current != win &&
"You cannot close a currently active window");
18744 if (ctx->
current == win)
return;
18752 NK_ASSERT(ctx); NK_ASSERT(ctx->
current);
18753 if (!ctx || !ctx->
current)
return;
18760 NK_ASSERT(ctx); NK_ASSERT(ctx->
current);
18761 if (!ctx || !ctx->
current)
return;
18769 NK_ASSERT(ctx); NK_ASSERT(ctx->
current);
18770 if (!ctx || !ctx->
current)
return;
18780 nk_hash title_hash;
18787 win = nk_find_window(ctx, title_hash, name);
18799 if (!ctx || !cond)
return;
18807 nk_hash title_hash;
18814 win = nk_find_window(ctx, title_hash, name);
18826 if (!ctx || !cond)
return;
18834 nk_hash title_hash;
18841 win = nk_find_window(ctx, title_hash, name);
18842 if (win && ctx->
end != win) {
18843 nk_remove_window(ctx, win);
18844 nk_insert_window(ctx, win, NK_INSERT_BACK);
18930 float total_space,
int columns)
18932 float panel_padding;
18933 float panel_spacing;
18940 padding = nk_panel_get_padding(style, type);
18943 panel_padding = 2 * padding.
x;
18944 panel_spacing = (float)
NK_MAX(columns - 1, 0) * spacing.x;
18945 panel_space = total_space - panel_padding - panel_spacing;
18946 return panel_space;
18951 float height,
int cols)
18968 style = &ctx->
style;
18986 layout->
row.
height = height + item_spacing.y;
18991 background.x = win->
bounds.
x;
18992 background.w = win->
bounds.
w;
18993 background.y = layout->
at_y - 1.0f;
18994 background.h = layout->
row.
height + 1.0f;
19001 float height,
int cols,
int width)
19012 nk_panel_layout(ctx, win, height, cols);
19028 NK_ASSERT(pixel_width);
19048 float row_height,
int cols)
19061 nk_panel_layout(ctx, win, row_height, cols);
19092 float ratio = ratio_or_width;
19093 if ((ratio + layout->
row.
filled) > 1.0f)
return;
19123 float height,
int cols,
const float *ratio)
19138 nk_panel_layout(ctx, win, height, cols);
19143 for (i = 0; i < cols; ++i) {
19144 if (ratio[i] < 0.0f)
19146 else r += ratio[i];
19150 layout->
row.
item_width = (r > 0 && n_undef > 0) ? (r / (
float)n_undef):0;
19175 nk_panel_layout(ctx, win, height, 1);
19259 int variable_count = 0;
19260 int min_variable_count = 0;
19261 float min_fixed_width = 0.0f;
19262 float total_fixed_width = 0.0f;
19263 float max_variable_width = 0.0f;
19277 if (width >= 0.0f) {
19278 total_fixed_width += width;
19279 min_fixed_width += width;
19280 }
else if (width < -1.0f) {
19282 total_fixed_width += width;
19283 max_variable_width =
NK_MAX(max_variable_width, width);
19286 min_variable_count++;
19290 if (variable_count) {
19291 float space = nk_layout_row_calculate_usable_space(&ctx->
style, layout->
type,
19293 float var_width = (
NK_MAX(space-min_fixed_width,0.0f)) / (
float)variable_count;
19294 int enough_space = var_width >= max_variable_width;
19296 var_width = (
NK_MAX(space-total_fixed_width,0)) / (
float)min_variable_count;
19299 *width = (*width >= 0.0f)? *width: (*width < -1.0f && !enough_space)? -(*width): var_width;
19306 float height,
int widget_count)
19319 nk_panel_layout(ctx, win, height, widget_count);
19380 ret.x = layout->
clip.
x;
19381 ret.y = layout->
clip.
y;
19382 ret.w = layout->
clip.
w;
19394 NK_ASSERT(ctx->current);
19395 NK_ASSERT(ctx->current->layout);
19396 win = ctx->current;
19411 NK_ASSERT(ctx->current);
19412 NK_ASSERT(ctx->current->layout);
19413 win = ctx->current;
19428 NK_ASSERT(ctx->current);
19429 NK_ASSERT(ctx->current->layout);
19430 win = ctx->current;
19445 NK_ASSERT(ctx->current);
19446 NK_ASSERT(ctx->current->layout);
19447 win = ctx->current;
19460 const float row_height = layout->
row.
height - spacing.
y;
19461 nk_panel_layout(ctx, win, row_height, layout->
row.
columns);
19474 float item_offset = 0;
19475 float item_width = 0;
19476 float item_spacing = 0;
19477 float panel_space = 0;
19487 style = &ctx->
style;
19491 padding = nk_panel_get_padding(style, layout->
type);
19492 panel_space = nk_layout_row_calculate_usable_space(&ctx->
style, layout->
type,
19500 item_offset = (
float)layout->
row.
index * item_width;
19501 item_spacing = (float)layout->
row.
index * spacing.x;
19532 item_spacing = (
float)layout->
row.
index * spacing.x;
19533 item_width = (ratio * panel_space);
19544 item_offset = (float)layout->
row.
index * item_width;
19545 item_spacing = (
float)layout->
row.
index * spacing.x;
19551 item_spacing = (float)layout->
row.
index * spacing.x;
19558 if (((bounds->
x + bounds->
w) > layout->
max_x) && modify)
19559 layout->
max_x = (bounds->
x + bounds->
w);
19568 item_spacing = (float)layout->
row.
index * spacing.x;
19579 item_spacing = (float)layout->
row.
index * spacing.x;
19582 default: NK_ASSERT(0);
break;
19586 bounds->
w = item_width;
19589 bounds->
x = layout->
at_x + item_offset + item_spacing + padding.
x;
19590 if (((bounds->
x + bounds->
w) > layout->
max_x) && modify)
19591 layout->
max_x = bounds->
x + bounds->
w;
19611 nk_panel_alloc_row(ctx, win);
19614 nk_layout_widget_space(bounds, ctx, win,
nk_true);
19640 nk_layout_widget_space(bounds, ctx, win,
nk_false);
19658 struct nk_rect header = {0,0,0,0};
19659 struct nk_rect sym = {0,0,0,0};
19675 style = &ctx->
style;
19680 widget_state =
nk_widget(&header, ctx);
19685 text.background =
nk_rgba(0,0,0,0);
19687 text.background = background->
data.
color;
19718 button, 0, style->
font);
19722 sym.
x = sym.
x + sym.
w + 4 * item_spacing.x;
19729 header.
w =
NK_MAX(header.
w, sym.
w + item_spacing.x);
19730 label.
x = sym.
x + sym.
w + item_spacing.x;
19732 label.
w = header.
w - (sym.
w + item_spacing.y + style->
tab.
indent);
19736 nk_widget_text(out, label, title,
nk_strlen(title), &text,
19752 const char *hash,
int len,
int line)
19756 nk_hash tree_hash = 0;
19757 nk_uint *state = 0;
19762 tree_hash =
nk_murmur_hash(title, (
int)title_len, (nk_hash)line);
19764 state = nk_find_value(win, tree_hash);
19766 state = nk_add_value(ctx, win, tree_hash, 0);
19767 *state = initial_state;
19775 {
return nk_tree_state_base(ctx, type, 0, title, state);}
19780 {
return nk_tree_state_base(ctx, type, &img, title, state);}
19805 const char *hash,
int len,
int line)
19806 {
return nk_tree_base(ctx, type, 0, title, initial_state, hash, len, line);}
19811 const char *hash,
int len,
int seed)
19812 {
return nk_tree_base(ctx, type, &img, title, initial_state, hash, len, seed);}
19831 nk_layout_peek(&bounds, ctx);
19844 nk_layout_peek(&bounds, ctx);
19857 nk_layout_peek(&bounds, ctx);
19870 nk_layout_peek(&bounds, ctx);
19883 nk_layout_peek(&bounds, ctx);
19897 nk_layout_peek(&bounds, ctx);
19913 nk_layout_peek(&bounds, ctx);
19929 nk_layout_peek(&bounds, ctx);
19945 nk_layout_peek(&bounds, ctx);
19965 nk_panel_alloc_space(bounds, ctx);
19980 bounds->
x = (float)((
int)bounds->
x);
19981 bounds->
y = (float)((
int)bounds->
y);
19982 bounds->
w = (float)((
int)bounds->
w);
19983 bounds->
h = (float)((
int)bounds->
h);
19985 c.x = (float)((
int)c.x);
19986 c.y = (float)((
int)c.y);
19987 c.w = (float)((
int)c.w);
19988 c.h = (float)((
int)c.h);
19990 if (!
NK_INTERSECT(c.x, c.y, c.w, c.h, bounds->
x, bounds->
y, bounds->
w, bounds->
h))
19992 if (!
NK_CONTAINS(bounds->
x, bounds->
y, bounds->
w, bounds->
h, c.x, c.y, c.w, c.h))
20006 struct nk_vec2 panel_padding;
20015 style = &ctx->
style;
20019 panel_padding = nk_panel_get_padding(style, layout->
type);
20021 bounds->
w += panel_padding.x;
20022 bounds->
x -= panel_padding.x;
20023 }
else bounds->
x -= item_padding.
x;
20026 bounds->
w += panel_padding.x;
20027 else bounds->
w += item_padding.
x;
20042 int i, index, rows;
20056 for (i = 0; i < rows; ++i)
20057 nk_panel_alloc_row(ctx, win);
20064 for (i = 0; i < cols; ++i)
20065 nk_panel_alloc_space(&none, ctx);
20077 nk_flags alignment,
struct nk_color color)
20092 style = &ctx->
style;
20093 nk_panel_alloc_space(&bounds, ctx);
20100 nk_widget_text(&win->
buffer, bounds, str, len, &text, alignment, style->
font);
20120 style = &ctx->
style;
20121 nk_panel_alloc_space(&bounds, ctx);
20128 nk_widget_text_wrap(&win->
buffer, bounds, str, len, &text, style->
font);
20131 #ifdef NK_INCLUDE_STANDARD_VARARGS
20133 nk_labelf_colored(
struct nk_context *ctx, nk_flags flags,
20134 struct nk_color color,
const char *fmt, ...)
20138 va_start(args, fmt);
20139 nk_strfmt(buf,
NK_LEN(buf), fmt, args);
20146 const char *fmt, ...)
20150 va_start(args, fmt);
20151 nk_strfmt(buf,
NK_LEN(buf), fmt, args);
20157 nk_labelf(
struct nk_context *ctx, nk_flags flags,
const char *fmt, ...)
20161 va_start(args, fmt);
20162 nk_strfmt(buf,
NK_LEN(buf), fmt, args);
20168 nk_labelf_wrap(
struct nk_context *ctx,
const char *fmt,...)
20172 va_start(args, fmt);
20173 nk_strfmt(buf,
NK_LEN(buf), fmt, args);
20179 nk_value_bool(
struct nk_context *ctx,
const char *prefix,
int value)
20180 {nk_labelf(ctx,
NK_TEXT_LEFT,
"%s: %s", prefix, ((value) ?
"true":
"false"));}
20183 nk_value_int(
struct nk_context *ctx,
const char *prefix,
int value)
20184 {nk_labelf(ctx,
NK_TEXT_LEFT,
"%s: %d", prefix, value);}
20187 nk_value_uint(
struct nk_context *ctx,
const char *prefix,
unsigned int value)
20188 {nk_labelf(ctx,
NK_TEXT_LEFT,
"%s: %u", prefix, value);}
20191 nk_value_float(
struct nk_context *ctx,
const char *prefix,
float value)
20193 double double_value = (double)value;
20194 nk_labelf(ctx,
NK_TEXT_LEFT,
"%s: %.3f", prefix, double_value);
20199 {nk_labelf(ctx,
NK_TEXT_LEFT,
"%s: (%d, %d, %d, %d)", p, c.
r, c.
g, c.
b, c.
a);}
20205 nk_labelf(ctx,
NK_TEXT_LEFT,
"%s: (%.2f, %.2f, %.2f, %.2f)",
20206 p, c[0], c[1], c[2], c[3]);
20210 nk_value_color_hex(
struct nk_context *ctx,
const char *prefix,
struct nk_color color)
20283 struct nk_config_stack_button_behavior *button_stack;
20284 struct nk_config_stack_button_behavior_element *element;
20287 if (!ctx)
return 0;
20290 NK_ASSERT(button_stack->head < (
int)
NK_LEN(button_stack->elements));
20291 if (button_stack->head >= (
int)
NK_LEN(button_stack->elements))
20294 element = &button_stack->elements[button_stack->head++];
20304 struct nk_config_stack_button_behavior *button_stack;
20305 struct nk_config_stack_button_behavior_element *element;
20308 if (!ctx)
return 0;
20311 NK_ASSERT(button_stack->head > 0);
20312 if (button_stack->head < 1)
20315 element = &button_stack->elements[--button_stack->head];
20316 *element->address = element->old_value;
20341 if (!state)
return 0;
20352 if (!ctx)
return 0;
20386 if (!state)
return 0;
20419 if (!state)
return 0;
20429 if (!ctx)
return 0;
20454 if (!state)
return 0;
20464 if (!ctx)
return 0;
20471 const char *text,
int len, nk_flags align)
20490 if (!state)
return 0;
20499 const char* text,
int len, nk_flags align)
20502 if (!ctx)
return 0;
20507 const char *label, nk_flags align)
20512 const char *title, nk_flags align)
20518 int len, nk_flags align)
20537 if (!state)
return 0;
20546 const char *text,
int len, nk_flags align)
20551 const char *label, nk_flags align)
20556 const char *label, nk_flags text_alignment)
20566 nk_flags align,
int *value)
20585 style = &ctx->
style;
20588 if (!state)
return 0;
20596 const char *str,
int len, nk_flags align,
int *value)
20615 style = &ctx->
style;
20618 if (!state)
return 0;
20621 str, len, align, value, &img, &style->
selectable, in, style->
font);
20625 nk_flags align,
int value)
20632 const char *str, nk_flags align,
int *value)
20639 const char *str, nk_flags align,
int value)
20643 const char *str,
int len, nk_flags align,
int value)
20669 style = &ctx->
style;
20673 if (!state)
return active;
20676 text, len, NK_TOGGLE_CHECK, &style->
checkbox, in, style->
font);
20682 unsigned int flags,
unsigned int value)
20687 if (!ctx || !text)
return flags;
20688 old_active = (
int)((flags & value) &
value);
20691 else flags &= ~value;
20702 if (!ctx || !text || !active)
return 0;
20705 return old_val != *active;
20710 unsigned int *flags,
unsigned int value)
20716 if (!ctx || !text || !flags)
return 0;
20718 active = (
int)((*flags & value) &
value);
20720 if (active) *flags |=
value;
20721 else *flags &= ~value;
20731 unsigned int flags,
unsigned int value)
20738 unsigned int *flags,
unsigned int value)
20764 style = &ctx->
style;
20768 if (!state)
return state;
20771 text, len, NK_TOGGLE_OPTION, &style->
option, in, style->
font);
20782 if (!ctx || !text || !active)
return 0;
20783 old_value = *active;
20785 return old_value != *active;
20823 style = &ctx->
style;
20827 if (!state)
return ret;
20830 old_value = *value;
20832 old_value, max_value, value_step, &style->
slider, in, style->
font);
20833 return (old_value > *value || old_value < *value);
20845 float value = (float)val;
20854 float value = (float)*val;
20855 ret =
nk_slider_float(ctx, (
float)min, &value, (
float)max, (
float)step);
20885 style = &ctx->
style;
20888 if (!state)
return 0;
20893 *cur, max, is_modifyable, &style->
progress, in);
20894 return (*cur != old_value);
20898 {
nk_progress(ctx, &cur, max, modifyable);
return cur;}
20913 if (!ctx || !ctx->
current)
return;
20919 if (flags & NK_EDIT_ALWAYS_INSERT_MODE)
20929 if (!ctx || !ctx->
current)
return;
20948 if (!ctx || !memory || !len)
20955 nk_textedit_clear_state(&ctx->
text_edit, (flags & NK_EDIT_MULTILINE)?
20976 *len =
NK_MIN(*len, max-1);
21005 nk_flags ret_flags = 0;
21006 unsigned char prev_state;
21018 style = &ctx->
style;
21020 if (!state)
return state;
21026 if (flags & NK_EDIT_NO_CURSOR)
21032 if (flags & NK_EDIT_CLIPBOARD)
21037 prev_state = (
unsigned char)edit->
active;
21038 in = (flags & NK_EDIT_READ_ONLY) ? 0: in;
21040 filter, edit, &style->
edit, in, style->
font);
21048 }
else if (prev_state && !edit->
active) {
21072 nk_property_variant_int(int value, int min_value, int max_value, int step)
21074 struct nk_property_variant result;
21075 result.kind = NK_PROPERTY_INT;
21076 result.value.i =
value;
21077 result.min_value.i = min_value;
21078 result.max_value.i = max_value;
21079 result.step.i = step;
21084 nk_property_variant_float(float value, float min_value, float max_value, float step)
21086 struct nk_property_variant result;
21087 result.kind = NK_PROPERTY_FLOAT;
21088 result.value.f =
value;
21089 result.min_value.f = min_value;
21090 result.max_value.f = max_value;
21091 result.step.f = step;
21096 nk_property_variant_double(double value, double min_value, double max_value,
21099 struct nk_property_variant result;
21100 result.kind = NK_PROPERTY_DOUBLE;
21101 result.value.d =
value;
21102 result.min_value.d = min_value;
21103 result.max_value.d = max_value;
21104 result.step.d = step;
21109 nk_property(
struct nk_context *ctx,
const char *name,
struct nk_property_variant *variant,
21110 float inc_per_pixel,
const enum nk_property_filter filter)
21125 int *select_begin = 0;
21126 int *select_end = 0;
21130 int dummy_state = NK_PROPERTY_DEFAULT;
21131 int dummy_length = 0;
21132 int dummy_cursor = 0;
21133 int dummy_select_begin = 0;
21134 int dummy_select_end = 0;
21144 style = &ctx->
style;
21150 if (name[0] ==
'#') {
21164 buffer = dummy_buffer;
21165 len = &dummy_length;
21166 cursor = &dummy_cursor;
21167 state = &dummy_state;
21168 select_begin = &dummy_select_begin;
21169 select_end = &dummy_select_end;
21173 old_state = *state;
21176 variant, inc_per_pixel, buffer, len, state, cursor, select_begin,
21180 if (in && *state != NK_PROPERTY_DEFAULT && !win->
property.
active) {
21190 if (*state == NK_PROPERTY_DRAG) {
21197 if (*state == NK_PROPERTY_DEFAULT && old_state != NK_PROPERTY_DEFAULT) {
21198 if (old_state == NK_PROPERTY_DRAG) {
21209 int min,
int *val,
int max,
int step,
float inc_per_pixel)
21211 struct nk_property_variant variant;
21216 if (!ctx || !ctx->
current || !name || !val)
return;
21217 variant = nk_property_variant_int(*val, min, max, step);
21218 nk_property(ctx, name, &variant, inc_per_pixel, NK_FILTER_INT);
21219 *val = variant.value.i;
21224 float min,
float *val,
float max,
float step,
float inc_per_pixel)
21226 struct nk_property_variant variant;
21231 if (!ctx || !ctx->
current || !name || !val)
return;
21232 variant = nk_property_variant_float(*val, min, max, step);
21233 nk_property(ctx, name, &variant, inc_per_pixel, NK_FILTER_FLOAT);
21234 *val = variant.value.f;
21239 double min,
double *val,
double max,
double step,
float inc_per_pixel)
21241 struct nk_property_variant variant;
21246 if (!ctx || !ctx->
current || !name || !val)
return;
21247 variant = nk_property_variant_double(*val, min, max, step);
21248 nk_property(ctx, name, &variant, inc_per_pixel, NK_FILTER_FLOAT);
21249 *val = variant.value.d;
21254 int max,
int step,
float inc_per_pixel)
21256 struct nk_property_variant variant;
21260 if (!ctx || !ctx->
current || !name)
return val;
21261 variant = nk_property_variant_int(val, min, max, step);
21262 nk_property(ctx, name, &variant, inc_per_pixel, NK_FILTER_INT);
21263 val = variant.value.i;
21269 float val,
float max,
float step,
float inc_per_pixel)
21271 struct nk_property_variant variant;
21275 if (!ctx || !ctx->
current || !name)
return val;
21276 variant = nk_property_variant_float(val, min, max, step);
21277 nk_property(ctx, name, &variant, inc_per_pixel, NK_FILTER_FLOAT);
21278 val = variant.value.f;
21284 double val,
double max,
double step,
float inc_per_pixel)
21286 struct nk_property_variant variant;
21290 if (!ctx || !ctx->
current || !name)
return val;
21291 variant = nk_property_variant_double(val, min, max, step);
21292 nk_property(ctx, name, &variant, inc_per_pixel, NK_FILTER_FLOAT);
21293 val = variant.value.d;
21322 config = &ctx->
style;
21325 if (!state)
return 0;
21347 int count,
float min_value,
float max_value)
21355 struct nk_rect bounds = {0, 0, 0, 0};
21364 nk_zero(chart,
sizeof(*chart));
21369 config = &ctx->
style;
21371 style = &config->
chart;
21374 nk_zero(chart,
sizeof(*chart));
21388 slot->
min =
NK_MIN(min_value, max_value);
21389 slot->
max =
NK_MAX(min_value, max_value);
21406 int count,
float min_value,
float max_value)
21412 int count,
float min_value,
float max_value)
21428 slot->
min =
NK_MIN(min_value, max_value);
21429 slot->
max =
NK_MAX(min_value, max_value);
21435 int count,
float min_value,
float max_value)
21440 struct nk_chart *g,
float value,
int slot)
21457 ratio = (value - g->
slots[slot].
min) / range;
21462 g->
slots[slot].
last.
y = (g->
y + g->
h) - ratio * (
float)g->
h;
21466 bounds.
w = bounds.
h = 4;
21483 cur.x = g->
x + (float)(step * (
float)g->
slots[slot].
index);
21484 cur.y = (g->
y + g->
h) - (ratio * (
float)g->
h);
21487 bounds.
x = cur.x - 3;
21488 bounds.
y = cur.y - 3;
21489 bounds.
w = bounds.
h = 6;
21511 struct nk_chart *chart,
float value,
int slot)
21520 struct nk_rect item = {0,0,0,0};
21526 float padding = (float)(chart->
slots[slot].
count-1);
21527 item.
w = (chart->
w - padding) / (
float)(chart->
slots[slot].
count);
21535 item.
y = (chart->
y + chart->
h) - chart->
h * ratio;
21538 item.
y = chart->
y + (chart->
h *
NK_ABS(ratio)) - item.
h;
21540 item.
x = chart->
x + ((float)chart->
slots[slot].
index * item.
w);
21565 NK_ASSERT(slot < ctx->
current->layout->chart.slot);
21573 flags = nk_chart_push_line(ctx, win, &win->
layout->
chart, value, slot);
break;
21575 flags = nk_chart_push_column(ctx, win, &win->
layout->
chart, value, slot);
break;
21600 NK_MEMSET(chart, 0,
sizeof(*chart));
21606 int count,
int offset)
21614 if (!ctx || !values || !count)
return;
21616 min_value = values[offset];
21617 max_value = values[offset];
21618 for (i = 0; i < count; ++i) {
21619 min_value =
NK_MIN(values[i + offset], min_value);
21620 max_value =
NK_MAX(values[i + offset], max_value);
21623 for (i = 0; i < count; ++i)
21630 float(*value_getter)(
void* user,
int index),
int count,
int offset)
21637 NK_ASSERT(value_getter);
21638 if (!ctx || !value_getter || !count)
return;
21640 max_value = min_value = value_getter(userdata, offset);
21641 for (i = 0; i < count; ++i) {
21642 float value = value_getter(userdata, i + offset);
21643 min_value =
NK_MIN(value, min_value);
21644 max_value =
NK_MAX(value, max_value);
21647 for (i = 0; i < count; ++i)
21659 nk_uint *x_offset, nk_uint *y_offset,
const char *title, nk_flags flags)
21666 nk_panel_alloc_space(&bounds, ctx);
21676 nk_zero(&panel,
sizeof(panel));
21677 panel.bounds = bounds;
21678 panel.flags = flags;
21679 panel.scrollbar.
x = *x_offset;
21680 panel.scrollbar.y = *y_offset;
21681 panel.buffer = win->
buffer;
21682 panel.layout = (
struct nk_panel*)nk_create_panel(ctx);
21686 win->
buffer = panel.buffer;
21688 panel.layout->offset_x = x_offset;
21689 panel.layout->offset_y = y_offset;
21690 panel.layout->parent = win->
layout;
21691 win->
layout = panel.layout;
21697 nk_flags f = panel.layout->flags;
21716 struct nk_vec2 panel_padding;
21735 pan.bounds.x = g->
bounds.
x - panel_padding.x;
21736 pan.bounds.w = g->
bounds.
w + 2 * panel_padding.x;
21738 if (g->
flags & NK_WINDOW_BORDER) {
21739 pan.bounds.x -= g->
border;
21740 pan.bounds.y -= g->
border;
21741 pan.bounds.w += 2*g->
border;
21742 pan.bounds.h += 2*g->
border;
21750 pan.flags = g->
flags;
21751 pan.buffer = win->
buffer;
21757 nk_unify(&clip, &parent->
clip, pan.bounds.
x, pan.bounds.y,
21758 pan.bounds.x + pan.bounds.w, pan.bounds.y + pan.bounds.h + panel_padding.x);
21762 win->
buffer = pan.buffer;
21772 struct nk_scroll *scroll,
const char *title, nk_flags flags)
21779 nk_hash title_hash;
21795 x_offset = nk_find_value(win, title_hash);
21797 x_offset = nk_add_value(ctx, win, title_hash, 0);
21798 y_offset = nk_add_value(ctx, win, title_hash+1, 0);
21800 NK_ASSERT(x_offset);
21801 NK_ASSERT(y_offset);
21802 if (!x_offset || !y_offset)
return 0;
21803 *x_offset = *y_offset = 0;
21804 }
else y_offset = nk_find_value(win, title_hash+1);
21814 const char *title, nk_flags flags,
int row_height,
int row_count)
21817 nk_hash title_hash;
21830 if (!ctx || !view || !title)
return 0;
21833 style = &ctx->
style;
21835 row_height +=
NK_MAX(0, (
int)item_spacing.y);
21840 x_offset = nk_find_value(win, title_hash);
21842 x_offset = nk_add_value(ctx, win, title_hash, 0);
21843 y_offset = nk_add_value(ctx, win, title_hash+1, 0);
21845 NK_ASSERT(x_offset);
21846 NK_ASSERT(y_offset);
21847 if (!x_offset || !y_offset)
return 0;
21848 *x_offset = *y_offset = 0;
21849 }
else y_offset = nk_find_value(win, title_hash+1);
21874 NK_ASSERT(view->
ctx);
21876 if (!view || !view->
ctx)
return;
21893 const char *title, nk_flags flags,
struct nk_rect rect)
21900 nk_hash title_hash;
21919 popup = (
struct nk_window*)nk_create_window(ctx);
21929 nk_zero(popup,
sizeof(*popup));
21952 nk_start_popup(ctx, win);
21982 nk_free_panel(ctx, popup->
layout);
22012 popup = (
struct nk_window*)nk_create_window(ctx);
22019 int pressed, in_body, in_header;
22023 if (pressed && (!in_body || in_header))
22046 NK_ASSERT(popup->
layout);
22048 nk_start_popup(ctx, win);
22053 nk_panel_begin(ctx, 0, panel_type);
22074 if (!ctx || !ctx->
current)
return;
22077 NK_ASSERT(popup->
parent);
22095 if (!popup->
parent)
return;
22110 nk_finish_popup(ctx, win);
22140 bounds.
h = nk_null_rect.h;
22157 if (!ctx || !ctx->
current)
return;
22181 style = &ctx->
style;
22188 text_width += (4 * padding.x);
22189 text_height = (style->
font->
height + 2 * padding.y);
22205 struct nk_rect trigger_bounds)
22212 int is_clicked = 0;
22232 if ((is_clicked && is_open && !is_active) || (!is_open && !is_active && !is_clicked))
22261 nk_flags alignment)
22277 style = &ctx->
style;
22295 const char *text,
int len, nk_flags align)
22311 style = &ctx->
style;
22325 const char *label, nk_flags align)
22330 const char *text,
int len, nk_flags align)
22346 style = &ctx->
style;
22360 const char *text, nk_flags align)
22380 if (!ctx || !ctx->
current)
return;
22384 NK_ASSERT(popup->
parent);
22392 struct nk_rect body = {0,0,0,0};
22402 if (pressed && in_body)
22441 if ((is_clicked && is_open && !is_active) || (is_open && !is_active) ||
22442 (!is_open && !is_active && !is_clicked))
return 0;
22443 if (!nk_nonblock_begin(ctx, 0, body,
22466 NK_ASSERT(selected);
22473 style = &ctx->
style;
22494 text.background =
nk_rgba(0,0,0,0);
22497 text.background = background->
data.
color;
22510 else if (is_clicked)
22518 button.h = button.w;
22531 nk_widget_text(&win->
buffer, label, selected, len, &text,
22538 return nk_combo_begin(ctx, win, size, is_clicked, header);
22563 style = &ctx->
style;
22593 else if (is_clicked)
22601 button.h = button.w;
22619 return nk_combo_begin(ctx, win, size, is_clicked, header);
22643 style = &ctx->
style;
22665 sym_background =
nk_rgba(0,0,0,0);
22668 sym_background = background->
data.
color;
22673 struct nk_rect bounds = {0,0,0,0};
22680 else if (is_clicked)
22688 button.h = button.w;
22700 nk_draw_symbol(&win->
buffer, symbol, bounds, sym_background, symbol_color,
22701 1.0f, style->
font);
22707 return nk_combo_begin(ctx, win, size, is_clicked, header);
22732 style = &ctx->
style;
22755 text.background =
nk_rgba(0,0,0,0);
22758 text.background = background->
data.
color;
22771 else if (is_clicked)
22779 button.h = button.w;
22793 nk_draw_symbol(&win->
buffer, symbol, image, text.background, symbol_color,
22794 1.0f, style->
font);
22804 return nk_combo_begin(ctx, win, size, is_clicked, header);
22826 style = &ctx->
style;
22849 struct nk_rect bounds = {0,0,0,0};
22856 else if (is_clicked)
22864 button.h = button.w;
22882 return nk_combo_begin(ctx, win, size, is_clicked, header);
22906 style = &ctx->
style;
22926 text.background =
nk_rgba(0,0,0,0);
22929 text.background = background->
data.
color;
22942 else if (is_clicked)
22950 button.h = button.w;
22974 return nk_combo_begin(ctx, win, size, is_clicked, header);
22992 int len, nk_flags alignment)
22996 const char *text, nk_flags alignment)
23000 const char *text,
int len, nk_flags alignment)
23004 const char *label, nk_flags alignment)
23015 int selected,
int item_height,
struct nk_vec2 size)
23020 struct nk_vec2 window_padding;
23025 if (!ctx || !items ||!count)
23030 max_height = count * item_height + count * (
int)item_spacing.y;
23031 max_height += (
int)item_spacing.y * 2 + (
int)window_padding.y * 2;
23032 size.
y =
NK_MIN(size.
y, (
float)max_height);
23035 for (i = 0; i < count; ++i) {
23046 int separator,
int selected,
int count,
int item_height,
struct nk_vec2 size)
23051 struct nk_vec2 window_padding;
23052 const char *current_item;
23057 NK_ASSERT(items_separated_by_separator);
23058 if (!ctx || !items_separated_by_separator)
23064 max_height = count * item_height + count * (
int)item_spacing.y;
23065 max_height += (
int)item_spacing.y * 2 + (
int)window_padding.y * 2;
23066 size.
y =
NK_MIN(size.
y, (
float)max_height);
23069 current_item = items_separated_by_separator;
23070 for (i = 0; i < count; ++i) {
23071 iter = current_item;
23072 while (*iter && *iter != separator) iter++;
23073 length = (
int)(iter - current_item);
23074 if (i == selected)
break;
23075 current_item = iter + 1;
23079 current_item = items_separated_by_separator;
23081 for (i = 0; i < count; ++i) {
23082 iter = current_item;
23083 while (*iter && *iter != separator) iter++;
23084 length = (
int)(iter - current_item);
23087 current_item = current_item + length + 1;
23096 int selected,
int count,
int item_height,
struct nk_vec2 size)
23097 {
return nk_combo_separator(ctx, items_separated_by_zeros,
'\0', selected, count, item_height, size);}
23101 void *userdata,
int selected,
int count,
int item_height,
struct nk_vec2 size)
23106 struct nk_vec2 window_padding;
23110 NK_ASSERT(item_getter);
23111 if (!ctx || !item_getter)
23117 max_height = count * item_height + count * (
int)item_spacing.y;
23118 max_height += (
int)item_spacing.y * 2 + (
int)window_padding.y * 2;
23119 size.
y =
NK_MIN(size.
y, (
float)max_height);
23121 item_getter(userdata, selected, &item);
23124 for (i = 0; i < count; ++i) {
23125 item_getter(userdata, i, &item);
23135 int *selected,
int item_height,
struct nk_vec2 size)
23136 {*selected =
nk_combo(ctx, items, count, *selected, item_height, size);}
23139 int *selected,
int count,
int item_height,
struct nk_vec2 size)
23140 {*selected =
nk_combo_string(ctx, items_separated_by_zeros, *selected, count, item_height, size);}
23143 int separator,
int *selected,
int count,
int item_height,
struct nk_vec2 size)
23145 *selected, count, item_height, size);}
23148 void(*item_getter)(
void* data,
int id,
const char **out_text),
23149 void *userdata,
int *selected,
int count,
int item_height,
struct nk_vec2 size)
23150 {*selected =
nk_combo_callback(ctx, item_getter, userdata, *selected, count, item_height, size);}
23161 const char *
id,
int is_clicked,
struct nk_rect header,
struct nk_vec2 size)
23177 body.
y = header.
y + header.
h;
23183 if ((is_clicked && is_open && !is_active) || (is_open && !is_active) ||
23184 (!is_open && !is_active && !is_clicked))
return 0;
23195 nk_flags align,
struct nk_vec2 size)
23211 if (!state)
return 0;
23216 return nk_menu_begin(ctx, win, title, is_clicked, header, size);
23220 const char *text, nk_flags align,
struct nk_vec2 size)
23241 if (!state)
return 0;
23246 return nk_menu_begin(ctx, win,
id, is_clicked, header, size);
23267 if (!state)
return 0;
23272 return nk_menu_begin(ctx, win,
id, is_clicked, header, size);
23293 if (!state)
return 0;
23299 return nk_menu_begin(ctx, win, title, is_clicked, header, size);
23303 const char *title, nk_flags align,
struct nk_image img,
struct nk_vec2 size)
23324 if (!state)
return 0;
23330 return nk_menu_begin(ctx, win, title, is_clicked, header, size);
23344 const char *label, nk_flags align)
23348 const char *text,
int len, nk_flags align)
23352 const char *text,
int len, nk_flags align)
23356 const char *label, nk_flags align)
Definition: nuklear.h:1902
unsigned short r
Definition: nuklear.h:2944
struct nk_vec2 padding
Definition: nuklear.h:3507
Definition: nuklear.h:3007
Definition: nuklear.h:2027
NK_API struct nk_color nk_rgb_iv(const int *rgb)
struct nk_command header
Definition: nuklear.h:2857
Definition: nuklear.h:689
short cx
Definition: nuklear.h:2943
NK_API int nk_menu_item_text(struct nk_context *, const char *, int, nk_flags align)
struct nk_style_item hover
Definition: nuklear.h:3457
nk_chart_event
Definition: nuklear.h:472
struct nk_vec2 padding
Definition: nuklear.h:3413
float preferred_x
Definition: nuklear.h:2741
struct nk_style_item hover_active
Definition: nuklear.h:3329
NK_API int nk_window_has_focus(const struct nk_context *)
NK_API int nk_menu_item_symbol_text(struct nk_context *, enum nk_symbol_type, const char *, int, nk_flags alignment)
Definition: nuklear.h:3726
struct nk_style_button dec_button
Definition: nuklear.h:3511
NK_API struct nk_rect nk_rectv(const float *xywh)
nk_handle userdata
Definition: nuklear.h:3416
Definition: nuklear.h:1890
#define NK_CONFIG_STACK(type, size)
Definition: nuklear.h:3930
struct nk_style_item cursor_hover
Definition: nuklear.h:3300
struct nk_command header
Definition: nuklear.h:2910
NK_API int nk_input_mouse_clicked(const struct nk_input *, enum nk_buttons, struct nk_rect)
struct nk_pool pool
Definition: nuklear.h:4036
struct nk_style_item active
Definition: nuklear.h:3360
NK_API int nk_select_text(struct nk_context *, const char *, int, nk_flags align, int value)
NK_API int nk_tree_state_image_push(struct nk_context *, enum nk_tree_type, struct nk_image, const char *title, enum nk_collapse_states *state)
unsigned int scrolled
Definition: nuklear.h:3860
NK_API void nk_window_set_position(struct nk_context *, struct nk_vec2 pos)
NK_API struct nk_color nk_rgba_bv(const nk_byte *rgba)
float menu_border
Definition: nuklear.h:3631
NK_API int nk_contextual_item_image_text(struct nk_context *, struct nk_image, const char *, int len, nk_flags alignment)
NK_API void nk_textedit_select_all(struct nk_text_edit *)
Definition: nuklear.h:2941
nk_convert_result
Definition: nuklear.h:970
NK_API int nk_button_symbol_label_styled(struct nk_context *ctx, const struct nk_style_button *style, enum nk_symbol_type symbol, const char *title, nk_flags align)
NK_API int nk_contextual_begin(struct nk_context *, nk_flags, struct nk_vec2, struct nk_rect trigger_bounds)
struct nk_vec2 last
Definition: nuklear.h:3711
struct nk_color text_hover
Definition: nuklear.h:3334
Definition: nuklear.h:3705
Definition: nuklear.h:2932
void * memory
Definition: nuklear.h:2538
struct nk_style_item cursor_normal
Definition: nuklear.h:3299
NK_API void nk_color_hex_rgb(char *output, struct nk_color)
Definition: nuklear.h:2041
float border
Definition: nuklear.h:3770
NK_API struct nk_rect nk_get_null_rect(void)
nk_buffer_allocation_type
Definition: nuklear.h:2551
NK_API int nk_begin(struct nk_context *ctx, const char *title, struct nk_rect bounds, nk_flags flags)
void *(* nk_plugin_alloc)(nk_handle, void *old, nk_size)
Definition: nuklear.h:478
struct nk_color color
Definition: nuklear.h:2946
#define NK_STORAGE
Definition: nuklear.h:287
nk_handle userdata
Definition: nuklear.h:3390
nk_widget_states
Definition: nuklear.h:1714
void(* nk_plugin_paste)(nk_handle, struct nk_text_edit *)
Definition: nuklear.h:481
Definition: nuklear.h:1184
float tooltip_border
Definition: nuklear.h:3633
float max_x
Definition: nuklear.h:3767
#define NK_INT32
Definition: nuklear.h:352
NK_API int nk_contextual_item_symbol_text(struct nk_context *, enum nk_symbol_type, const char *, int, nk_flags alignment)
NK_API int nk_filter_default(const struct nk_text_edit *, nk_rune unicode)
unsigned int page_count
Definition: nuklear.h:3997
nk_size allocated
Definition: nuklear.h:2574
unsigned short w
Definition: nuklear.h:2893
NK_API int nk_widget_is_mouse_click_down(struct nk_context *, enum nk_buttons, int down)
NK_API void nk_stroke_circle(struct nk_command_buffer *, struct nk_rect, float line_thickness, struct nk_color)
NK_API struct nk_vec2 nk_vec2i(int x, int y)
Definition: nuklear.h:1183
struct nk_vec2 contextual_padding
Definition: nuklear.h:3645
Definition: nuklear.h:2042
nk_panel_flags
Definition: nuklear.h:1173
NK_API int nk_utf_decode(const char *, nk_rune *, int)
struct nk_style_button menu_button
Definition: nuklear.h:3660
Definition: nuklear.h:1896
NK_API struct nk_color nk_rgba_u32(nk_uint)
nk_size needed
Definition: nuklear.h:2576
NK_API int nk_filter_hex(const struct nk_text_edit *, nk_rune unicode)
NK_API int nk_menu_item_image_text(struct nk_context *, struct nk_image, const char *, int len, nk_flags alignment)
float bar_height
Definition: nuklear.h:3377
unsigned short w
Definition: nuklear.h:2886
NK_API void nk_buffer_init(struct nk_buffer *, const struct nk_allocator *, nk_size size)
NK_API int nk_button_color(struct nk_context *, struct nk_color)
unsigned short h
Definition: nuklear.h:2928
NK_API int nk_select_image_text(struct nk_context *, struct nk_image, const char *, int, nk_flags align, int value)
NK_API struct nk_window * nk_window_find(struct nk_context *ctx, const char *name)
NK_API void nk_str_remove_chars(struct nk_str *, int len)
NK_API int nk_widget_is_hovered(struct nk_context *)
#define NK_FLAGS_STACK_SIZE
Definition: nuklear.h:3918
NK_API void nk_layout_row_end(struct nk_context *)
Definition: nuklear.h:2820
Definition: nuklear.h:664
NK_API void nk_fill_circle(struct nk_command_buffer *, struct nk_rect, struct nk_color)
NK_API void nk_window_set_size(struct nk_context *, struct nk_vec2)
struct nk_vec2 padding
Definition: nuklear.h:3261
#define nk_zero_struct(s)
Definition: nuklear.h:4072
struct nk_image img
Definition: nuklear.h:462
Definition: nuklear.h:3800
Definition: deflate.c:117
Definition: nuklear.h:2553
nk_handle handle
Definition: nuklear.h:461
float border
Definition: nuklear.h:3505
Definition: nuklear.h:453
unsigned int seq
Definition: nuklear.h:3820
Definition: nuklear.h:3697
short x
Definition: nuklear.h:2852
enum nk_symbol_type sym_left
Definition: nuklear.h:3501
struct nk_config_stack_button_behavior button_behaviors
Definition: nuklear.h:3960
struct nk_rect clip
Definition: nuklear.h:3772
short y
Definition: nuklear.h:2892
Definition: nuklear.h:670
nk_modify
Definition: nuklear.h:467
Definition: nuklear.h:484
struct nk_color selected_text_hover
Definition: nuklear.h:3477
NK_API int nk_combo_callback(struct nk_context *, void(*item_getter)(void *, int, const char **), void *userdata, int selected, int count, int item_height, struct nk_vec2 size)
NK_API int nk_input_is_mouse_click_down_in_rect(const struct nk_input *i, enum nk_buttons id, struct nk_rect b, int down)
short h
Definition: nuklear.h:458
NK_API void nk_str_init_fixed(struct nk_str *, void *memory, nk_size size)
Definition: nuklear.h:3818
struct nk_color col
Definition: nuklear.h:2977
NK_API int nk_popup_begin(struct nk_context *, enum nk_popup_type, const char *, nk_flags, struct nk_rect bounds)
NK_API void nk_property_float(struct nk_context *, const char *name, float min, float *val, float max, float step, float inc_per_pixel)
NK_API void nk_layout_row_template_push_variable(struct nk_context *, float min_width)
nk_style_header_align
Definition: nuklear.h:3585
struct nk_vec2 touch_padding
Definition: nuklear.h:3311
Definition: nuklear.h:1888
NK_API int nk_button_text_styled(struct nk_context *, const struct nk_style_button *, const char *title, int len)
struct nk_row_layout row
Definition: nuklear.h:3774
unsigned short line_thickness
Definition: nuklear.h:2967
unsigned int seq
Definition: nuklear.h:3970
struct nk_style_button node_maximize_button
Definition: nuklear.h:3572
NK_API void nk_layout_space_push(struct nk_context *, struct nk_rect)
NK_API void nk_layout_row_template_push_static(struct nk_context *, float width)
int cursor
Definition: nuklear.h:3835
NK_API void nk_color_hsv_iv(int *hsv_out, struct nk_color)
struct nk_vec2 tooltip_padding
Definition: nuklear.h:3647
Definition: nuklear.h:465
NK_API void nk_combobox_callback(struct nk_context *, void(*item_getter)(void *, int, const char **), void *, int *selected, int count, int item_height, struct nk_vec2 size)
NK_API int nk_combo_item_text(struct nk_context *, const char *, int, nk_flags alignment)
Definition: nuklear.h:683
NK_API nk_flags nk_edit_string_zero_terminated(struct nk_context *, nk_flags, char *buffer, int max, nk_plugin_filter)
struct nk_window * current
Definition: nuklear.h:4040
NK_API void nk_text(struct nk_context *, const char *, int, nk_flags)
nk_flags flags
Definition: nuklear.h:3848
Definition: nuklear.h:2833
Definition: nuklear.h:3693
struct nk_color color
Definition: nuklear.h:2914
Definition: nuklear.h:3702
Definition: nuklear.h:3994
nk_uint values[NK_VALUE_PAGE_CAPACITY]
Definition: nuklear.h:3972
Definition: nuklear.h:1879
float border
Definition: nuklear.h:3527
NK_API int nk_select_label(struct nk_context *, const char *, nk_flags align, int value)
float h
Definition: nuklear.h:3717
NK_API int nk_menu_item_label(struct nk_context *, const char *, nk_flags alignment)
struct nk_color color
Definition: nuklear.h:2861
Definition: nuklear.h:3730
float cursor_size
Definition: nuklear.h:3482
struct nk_vec2i c
Definition: nuklear.h:2905
struct nk_color selected_text_normal
Definition: nuklear.h:3476
Definition: nuklear.h:3519
float w
Definition: nuklear.h:3717
Definition: nuklear.h:1751
NK_API int nk_button_symbol_styled(struct nk_context *, const struct nk_style_button *, enum nk_symbol_type)
float item_height
Definition: nuklear.h:3740
struct nk_color color
Definition: nuklear.h:2870
struct nk_chart_slot slots[NK_CHART_MAX_SLOT]
Definition: nuklear.h:3718
float border
Definition: nuklear.h:3313
struct nk_color text_normal_active
Definition: nuklear.h:3338
char nk_glyph[NK_UTF_SIZE]
Definition: nuklear.h:459
nk_plugin_free free
Definition: nuklear.h:487
NK_POINTER_TYPE nk_ptr
Definition: nuklear.h:402
NK_API struct nk_rect nk_layout_space_rect_to_local(struct nk_context *, struct nk_rect)
Definition: nuklear.h:492
nk_handle texture
Definition: nuklear.h:978
Definition: nuklear.h:1678
NK_API struct nk_color nk_hsv(int h, int s, int v)
struct nk_chart chart
Definition: nuklear.h:3775
struct nk_color tooltip_border_color
Definition: nuklear.h:3625
struct nk_vec2 image_padding
Definition: nuklear.h:3348
int where
Definition: nuklear.h:2699
nk_flags text_alignment
Definition: nuklear.h:3342
struct nk_vec2 cursor_size
Definition: nuklear.h:3380
struct nk_color group_border_color
Definition: nuklear.h:3624
struct nk_style_item scaler
Definition: nuklear.h:3626
Definition: nuklear.h:1174
#define NK_ABS(a)
Definition: nuklear.h:4056
nk_buttons
Definition: nuklear.h:695
NK_API void nk_edit_focus(struct nk_context *, nk_flags flags)
unsigned short point_count
Definition: nuklear.h:2953
Definition: nuklear.h:476
#define NK_MAX_FLOAT_PRECISION
Definition: nuklear.h:4051
#define NK_MAX_NUMBER_BUFFER
Definition: nuklear.h:260
unsigned char ungrab
Definition: nuklear.h:3057
short insert_length
Definition: nuklear.h:2700
short x
Definition: nuklear.h:2919
Definition: nuklear.h:3722
nk_edit_types
Definition: nuklear.h:1892
NK_API struct nk_color nk_hsv_fv(const float *hsv)
NK_API struct nk_style_item nk_style_item_image(struct nk_image img)
Definition: nuklear.h:1895
nk_anti_aliasing
Definition: nuklear.h:969
NK_API int nk_widget_is_mouse_clicked(struct nk_context *, enum nk_buttons)
struct nk_color bar_hover
Definition: nuklear.h:3365
struct nk_style_progress progress
Definition: nuklear.h:3665
NK_API void nk_window_collapse(struct nk_context *, const char *name, enum nk_collapse_states state)
Definition: nuklear.h:3691
short y
Definition: nuklear.h:458
Definition: nuklear.h:2055
NK_API void nk_button_set_behavior(struct nk_context *, enum nk_button_behavior)
nk_handle userdata
Definition: nuklear.h:2693
NK_API void nk_group_end(struct nk_context *)
NK_API int nk_input_is_key_pressed(const struct nk_input *, enum nk_keys)
unsigned short point_count
Definition: nuklear.h:2960
struct nk_style_item normal
Definition: nuklear.h:3323
#define NK_FLAG(x)
Definition: nuklear.h:290
unsigned short w
Definition: nuklear.h:2878
int32_t current
Definition: netobject.cpp:37
unsigned short line_thickness
Definition: nuklear.h:2858
#define NK_UTF_INVALID
Definition: nuklear.h:4050
unsigned short h
Definition: nuklear.h:2975
struct nk_color top
Definition: nuklear.h:2895
Definition: nuklear.h:3692
struct nk_property_state property
Definition: nuklear.h:3857
NK_API void nk_layout_space_end(struct nk_context *)
#define NK_GLOBAL
Definition: nuklear.h:288
struct nk_style_item active
Definition: nuklear.h:3458
struct nk_style_item cursor_hover
Definition: nuklear.h:3371
nk_flags flags
Definition: nuklear.h:3763
struct nk_color border_color
Definition: nuklear.h:3619
struct nk_color text_pressed
Definition: nuklear.h:3335
Definition: nuklear.h:1903
NK_API void nk_layout_row_template_push_dynamic(struct nk_context *)
short y
Definition: nuklear.h:2877
float min
Definition: nuklear.h:3709
unsigned short w
Definition: nuklear.h:2975
struct nk_page_element * freelist
Definition: nuklear.h:4041
Definition: nuklear.h:2725
Definition: nuklear.h:2890
NK_API int k_button_symbol_label_styled(struct nk_context *, const struct nk_style_button *, enum nk_symbol_type, const char *, nk_flags text_alignment)
struct nk_vec2i c
Definition: nuklear.h:2913
struct nk_style_selectable selectable
Definition: nuklear.h:3663
NK_API int nk_str_insert_str_runes(struct nk_str *, int pos, const nk_rune *)
void(* draw_begin)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:3515
enum nk_symbol_type sym_minimize
Definition: nuklear.h:3574
struct nk_style_button inc_button
Definition: nuklear.h:3384
nk_handle userdata
Definition: nuklear.h:3316
#define NK_ALIGNOF(t)
Definition: nuklear.h:4115
Definition: nuklear.h:969
struct nk_style_window window
Definition: nuklear.h:3673
float height
Definition: nuklear.h:3736
unsigned char grab
Definition: nuklear.h:3055
int select_start
Definition: nuklear.h:2732
struct nk_vec2i ctrl[2]
Definition: nuklear.h:2869
float group_border
Definition: nuklear.h:3632
NK_API void nk_stroke_triangle(struct nk_command_buffer *, float, float, float, float, float, float, float line_thichness, struct nk_color)
NK_SIZE_TYPE nk_size
Definition: nuklear.h:401
unsigned short w
Definition: nuklear.h:2853
Definition: nuklear.h:3789
unsigned short line_thickness
Definition: nuklear.h:2902
struct nk_color border_color
Definition: nuklear.h:3459
struct nk_color text_normal
Definition: nuklear.h:3333
nk_panel_row_layout_type
Definition: nuklear.h:3721
struct nk_style_button contextual_button
Definition: nuklear.h:3659
Definition: nuklear.h:3060
NK_API void nk_label_wrap(struct nk_context *, const char *)
NK_API struct nk_color nk_hsv_bv(const nk_byte *hsv)
Definition: nuklear.h:465
NK_API int nk_strmatch_fuzzy_text(const char *txt, int txt_len, const char *pattern, int *out_score)
NK_API void nk_window_set_focus(struct nk_context *, const char *name)
Definition: nuklear.h:1175
Definition: nuklear.h:2031
NK_API void nk_str_delete_runes(struct nk_str *, int pos, int len)
#define NK_POINTER_TYPE
Definition: nuklear.h:389
Definition: nuklear.h:663
::std::string string
Definition: gtest-port.h:872
unsigned int seq
Definition: nuklear.h:3839
NK_API struct nk_color nk_hsva_bv(const nk_byte *hsva)
#define SEEK_END
Definition: zconf.h:390
NK_API int nk_utf_encode(nk_rune, char *, int)
NK_API void nk_color_hsv_f(float *out_h, float *out_s, float *out_v, struct nk_color)
nk_byte r
Definition: nuklear.h:453
float a[2]
Definition: nuklear.h:2937
Definition: nuklear.h:2720
NK_API int nk_str_append_text_char(struct nk_str *, const char *, int)
struct nk_color border_color
Definition: nuklear.h:3537
NK_API void nk_fill_rect_multi_color(struct nk_command_buffer *, struct nk_rect, struct nk_color left, struct nk_color top, struct nk_color right, struct nk_color bottom)
struct nk_memory memory
Definition: nuklear.h:2570
NK_API void nk_list_view_end(struct nk_list_view *)
struct nk_color color
Definition: nuklear.h:2966
float header_height
Definition: nuklear.h:3769
void(* draw_end)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:3418
NK_API struct nk_vec2 nk_layout_space_to_local(struct nk_context *, struct nk_vec2)
struct nk_image img
Definition: nuklear.h:2976
NK_API char * nk_str_at_rune(struct nk_str *, int pos, nk_rune *unicode, int *len)
struct nk_mouse_button buttons[NK_BUTTON_MAX]
Definition: nuklear.h:3050
Definition: nuklear.h:1722
unsigned char has_preferred_x
Definition: nuklear.h:2737
NK_API struct nk_rect nk_layout_space_rect_to_screen(struct nk_context *, struct nk_rect)
struct nk_window * parent
Definition: nuklear.h:3869
int index
Definition: nuklear.h:3735
Definition: nuklear.h:458
union nk_style_item_data data
Definition: nuklear.h:3256
float border
Definition: nuklear.h:3375
Definition: nuklear.h:691
NK_API nk_uint nk_color_u32(struct nk_color)
NK_API struct nk_vec2 nk_widget_position(struct nk_context *)
struct nk_color background
Definition: nuklear.h:3617
NK_API int nk_button_symbol_text(struct nk_context *, enum nk_symbol_type, const char *, int, nk_flags alignment)
NK_API int nk_filter_ascii(const struct nk_text_edit *, nk_rune unicode)
Definition: nuklear.h:3695
struct nk_color bottom
Definition: nuklear.h:2896
nk_popup_type
Definition: nuklear.h:474
int prev
Definition: nuklear.h:3832
NK_API int nk_contextual_item_text(struct nk_context *, const char *, int, nk_flags align)
struct nk_page_element * next
Definition: nuklear.h:3984
nk_uint nk_flags
Definition: nuklear.h:405
float at_x
Definition: nuklear.h:3767
Definition: nuklear.h:3245
NK_API int nk_str_insert_text_char(struct nk_str *, int pos, const char *, int)
int count
Definition: nuklear.h:3710
struct nk_window * active
Definition: nuklear.h:4039
struct nk_color highlight
Definition: nuklear.h:3708
struct nk_color color
Definition: nuklear.h:3524
float rounding
Definition: nuklear.h:3579
float at_y
Definition: nuklear.h:3767
Definition: nuklear.h:2827
struct nk_style_text text
Definition: nuklear.h:3657
struct nk_vec2i b
Definition: nuklear.h:2912
nk_handle userdata
Definition: nuklear.h:3351
struct nk_color text_pressed_active
Definition: nuklear.h:3340
struct nk_color label_normal
Definition: nuklear.h:3540
struct nk_color combo_border_color
Definition: nuklear.h:3621
NK_API void nk_textedit_text(struct nk_text_edit *, const char *, int total_len)
NK_API void nk_str_delete_chars(struct nk_str *, int pos, int len)
Definition: nuklear.h:2836
struct nk_color color
Definition: nuklear.h:3251
struct nk_allocator alloc
Definition: nuklear.h:3995
NK_API int nk_str_append_text_runes(struct nk_str *, const nk_rune *, int)
#define NK_INT8
Definition: nuklear.h:337
nk_command_custom_callback callback
Definition: nuklear.h:2987
Definition: nuklear.h:668
std::mutex m
Definition: faio.cpp:21
NK_API void nk_color_f(float *r, float *g, float *b, float *a, struct nk_color)
Definition: nuklear.h:2547
NK_INT8 nk_char
Definition: nuklear.h:394
NK_API void nk_color_hsv_bv(nk_byte *hsv_out, struct nk_color)
Definition: nuklear.h:1882
struct nk_table * tables
Definition: nuklear.h:3862
struct nk_vec2 scrollbar_size
Definition: nuklear.h:3638
NK_API int nk_strtoi(const char *str, const char **endptr)
float max
Definition: nuklear.h:3709
struct nk_vec2 prev
Definition: nuklear.h:3052
enum nk_symbol_type sym_normal
Definition: nuklear.h:3551
Definition: nuklear.h:1881
Definition: nuklear.h:2722
struct nk_table * next
Definition: nuklear.h:3973
struct nk_style_item cursor_hover
Definition: nuklear.h:3404
struct nk_key keys[NK_KEY_MAX]
Definition: nuklear.h:3065
Definition: nuklear.h:3969
NK_API struct nk_style_item nk_style_item_hide(void)
NK_API int nk_combo_item_symbol_text(struct nk_context *, enum nk_symbol_type, const char *, int, nk_flags alignment)
unsigned short line_thickness
Definition: nuklear.h:2952
NK_API void nk_label(struct nk_context *, const char *, nk_flags align)
nk_byte g
Definition: nuklear.h:453
Definition: nuklear.h:1715
NK_API int nk_style_set_cursor(struct nk_context *, enum nk_style_cursor)
Definition: nuklear.h:3715
int count
Definition: nuklear.h:1680
NK_API const struct nk_command * nk__next(struct nk_context *, const struct nk_command *)
nk_tree_type
Definition: nuklear.h:476
NK_API int nk_stricmp(const char *s1, const char *s2)
Definition: nuklear.h:3488
NK_API int nk_str_insert_at_rune(struct nk_str *, int pos, const char *, int)
NK_API void nk_plot(struct nk_context *, enum nk_chart_type, const float *values, int count, int offset)
unsigned curve_segment_count
Definition: nuklear.h:987
nk_panel_type
Definition: nuklear.h:3690
short undo_point
Definition: nuklear.h:2708
int cursor
Definition: nuklear.h:2731
void(* draw_begin)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:3391
float delta_time_seconds
Definition: nuklear.h:4014
NK_API void nk_contextual_end(struct nk_context *)
NK_API int nk_combo_item_symbol_label(struct nk_context *, enum nk_symbol_type, const char *, nk_flags alignment)
struct nk_command_buffer overlay
Definition: nuklear.h:4031
struct nk_command header
Definition: nuklear.h:2874
NK_API int nk_progress(struct nk_context *, nk_size *cur, nk_size max, int modifyable)
float rounding
Definition: nuklear.h:3409
short y
Definition: nuklear.h:2974
nk_size needed
Definition: nuklear.h:2542
struct nk_style_item normal
Definition: nuklear.h:3534
struct nk_vec2i begin
Definition: nuklear.h:2859
Definition: nuklear.h:1744
void(* draw_begin)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:3352
struct nk_buffer buffer
Definition: nuklear.h:2610
struct nk_vec2i a
Definition: nuklear.h:2903
struct nk_style_item active
Definition: nuklear.h:3399
struct nk_style_edit edit
Definition: nuklear.h:3667
NK_API int nk_window_is_any_hovered(struct nk_context *)
Definition: nuklear.h:473
Definition: nuklear.h:3049
NK_API struct nk_vec2 nk_vec2iv(const int *xy)
unsigned short h
Definition: nuklear.h:2853
short cy
Definition: nuklear.h:2934
Definition: nuklear.h:969
unsigned char cursor_at_end_of_line
Definition: nuklear.h:2735
float border
Definition: nuklear.h:3628
NK_API int nk_combo_begin_text(struct nk_context *, const char *selected, int, struct nk_vec2 size)
#define NK_BUTTON_BEHAVIOR_STACK_SIZE
Definition: nuklear.h:3898
struct nk_style_button dec_button
Definition: nuklear.h:3385
NK_API void nk_input_glyph(struct nk_context *, const nk_glyph)
struct nk_style_item pressed_active
Definition: nuklear.h:3330
Definition: nuklear.h:475
nk_button_behavior
Definition: nuklear.h:466
NK_API struct nk_vec2 nk_layout_space_to_screen(struct nk_context *, struct nk_vec2)
NK_API int nk_style_pop_float(struct nk_context *)
short y
Definition: nuklear.h:2984
float rounding
Definition: nuklear.h:3506
NK_API struct nk_rect nk_layout_space_bounds(struct nk_context *)
struct nk_table * prev
Definition: nuklear.h:3973
NK_API int nk_button_image_text_styled(struct nk_context *, const struct nk_style_button *, struct nk_image img, const char *, int, nk_flags alignment)
NK_API int nk_init_custom(struct nk_context *, struct nk_buffer *cmds, struct nk_buffer *pool, const struct nk_user_font *)
struct nk_vec2i points[1]
Definition: nuklear.h:2954
Definition: nuklear.h:661
struct nk_style_tab tab
Definition: nuklear.h:3671
struct nk_color border_color
Definition: nuklear.h:3296
NK_API enum nk_widget_layout_states nk_widget_fitting(struct nk_rect *, struct nk_context *, struct nk_vec2)
NK_API double nk_strtod(const char *str, const char **endptr)
struct nk_window win
Definition: nuklear.h:3979
NK_API void nk_window_close(struct nk_context *ctx, const char *name)
struct nk_clipboard clip
Definition: nuklear.h:2726
nk_style_cursor
Definition: nuklear.h:2048
struct nk_window * begin
Definition: nuklear.h:4037
NK_API void nk_style_default(struct nk_context *)
NK_API void nk_input_scroll(struct nk_context *, struct nk_vec2 val)
NK_API int nk_input_has_mouse_click_down_in_rect(const struct nk_input *, enum nk_buttons, struct nk_rect, int down)
#define NK_FLOAT_STACK_SIZE
Definition: nuklear.h:3910
Definition: nuklear.h:1719
Definition: nuklear.h:3395
Definition: nuklear.h:2838
Definition: nuklear.h:3700
float y
Definition: nuklear.h:3717
Definition: nuklear.h:3701
int active
Definition: nuklear.h:3832
Definition: nuklear.h:665
NK_API void nk_free(struct nk_context *)
struct nk_color text_normal
Definition: nuklear.h:3469
unsigned short point_count
Definition: nuklear.h:2968
Definition: nuklear.h:496
int buffer_size
Definition: versiongenerate.py:65
Definition: nuklear.h:971
NK_API char * nk_str_at_char(struct nk_str *, int pos)
Definition: nuklear.h:699
Definition: nuklear.h:697
NK_API int nk_button_label_styled(struct nk_context *, const struct nk_style_button *, const char *title)
NK_API struct nk_color nk_rgb(int r, int g, int b)
NK_API int nk_tree_push_hashed(struct nk_context *, enum nk_tree_type, const char *title, enum nk_collapse_states initial_state, const char *hash, int len, int seed)
Definition: nuklear.h:474
enum nk_symbol_type sym_active
Definition: nuklear.h:3553
Definition: nuklear.h:500
NK_API void nk_combobox_separator(struct nk_context *, const char *items_separated_by_separator, int separator, int *selected, int count, int item_height, struct nk_vec2 size)
unsigned int has_scrolling
Definition: nuklear.h:3771
int len
Definition: nuklear.h:2611
unsigned int type
Definition: nuklear.h:2539
NK_API void nk_tree_state_pop(struct nk_context *)
NK_API int nk_combo_begin_label(struct nk_context *, const char *selected, struct nk_vec2 size)
NK_API int nk_stricmpn(const char *s1, const char *s2, int n)
Definition: nuklear.h:672
#define NK_UINT32
Definition: nuklear.h:359
NK_API int nk_style_push_flags(struct nk_context *, nk_flags *, nk_flags)
int select_start
Definition: nuklear.h:3836
int index
Definition: nuklear.h:3712
struct nk_style_item active
Definition: nuklear.h:3536
NK_API void nk_window_collapse_if(struct nk_context *, const char *name, enum nk_collapse_states, int cond)
Definition: nuklear.h:1889
struct nk_vec2 button_padding
Definition: nuklear.h:3559
Definition: nuklear.h:1742
float contextual_border
Definition: nuklear.h:3630
Definition: nuklear.h:2040
Definition: nuklear.h:1181
char text[NK_INPUT_MAX]
Definition: nuklear.h:3066
void(* nk_plugin_copy)(nk_handle, const char *, int len)
Definition: nuklear.h:482
unsigned char active
Definition: nuklear.h:2739
float templates[NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS]
Definition: nuklear.h:3745
NK_API void nk_buffer_push(struct nk_buffer *, enum nk_buffer_allocation_type type, const void *memory, nk_size size, nk_size align)
NK_API struct nk_vec2 nk_window_get_position(const struct nk_context *ctx)
NK_API void nk_color_fv(float *rgba_out, struct nk_color)
int state
Definition: nuklear.h:3841
NK_API int nk_input_is_mouse_prev_hovering_rect(const struct nk_input *, struct nk_rect)
Definition: nuklear.h:2716
Definition: nuklear.h:3454
nk_keys
Definition: nuklear.h:660
unsigned arc_segment_count
Definition: nuklear.h:986
#define NK_INT16
Definition: nuklear.h:343
struct nk_command header
Definition: nuklear.h:2973
Definition: nuklear.h:2830
Definition: nuklear.h:3586
NK_API void nk_layout_row_static(struct nk_context *ctx, float height, int item_width, int cols)
nk_size end
Definition: nuklear.h:3012
nk_style_item_type
Definition: nuklear.h:3244
const struct nk_cursor * cursor_active
Definition: nuklear.h:3653
Definition: nuklear.h:2557
unsigned circle_segment_count
Definition: nuklear.h:985
enum nk_symbol_type dec_symbol
Definition: nuklear.h:3387
int prev
Definition: nuklear.h:3822
struct nk_command header
Definition: nuklear.h:2901
Definition: nuklear.h:2609
struct nk_command header
Definition: nuklear.h:2851
Definition: nuklear.h:2034
Definition: nuklear.h:1883
Definition: nuklear.h:467
Definition: nuklear.h:3794
struct nk_vec2i b
Definition: nuklear.h:2904
struct nk_style_button button
Definition: nuklear.h:3658
Definition: nuklear.h:1177
struct nk_style_scrollbar scrollh
Definition: nuklear.h:3669
Definition: nuklear.h:1718
NK_API int nk_input_is_mouse_click_in_rect(const struct nk_input *, enum nk_buttons, struct nk_rect)
NK_API void nk_group_scrolled_end(struct nk_context *)
const float * ratio
Definition: nuklear.h:3738
NK_API int nk_contextual_item_symbol_label(struct nk_context *, enum nk_symbol_type, const char *, nk_flags alignment)
unsigned char single_line
Definition: nuklear.h:2738
Definition: nuklear.h:1893
Definition: nuklear.h:1178
struct nk_color foreground
Definition: nuklear.h:2994
struct nk_vec2 padding
Definition: nuklear.h:3641
Definition: nuklear.h:2026
struct nk_table tbl
Definition: nuklear.h:3977
struct nk_panel * parent
Definition: nuklear.h:3777
struct nk_style_item normal
Definition: nuklear.h:3490
struct nk_vec2 scrollbar
Definition: nuklear.h:2729
NK_API struct nk_vec2 nk_vec2(float x, float y)
unsigned char padding1
Definition: nuklear.h:2740
NK_API void nk_menubar_end(struct nk_context *)
struct nk_vec2 scrollbar_size
Definition: nuklear.h:3483
NK_API void nk_buffer_mark(struct nk_buffer *, enum nk_buffer_allocation_type type)
#define NK_WINDOW_MAX_NAME
Definition: nuklear.h:3784
Definition: nuklear.h:676
nk_uint * offset_x
Definition: nuklear.h:3765
int begin
Definition: nuklear.h:1680
typedef void(ENET_CALLBACK *ENetPacketFreeCallback)(struct _ENetPacket *)
struct nk_config_stack_user_font fonts
Definition: nuklear.h:3959
union nk_page_data data
Definition: nuklear.h:3983
Definition: nuklear.h:1886
NK_API int nk_combo_begin_symbol(struct nk_context *, enum nk_symbol_type, struct nk_vec2 size)
NK_API void nk_image(struct nk_context *, struct nk_image)
float footer_height
Definition: nuklear.h:3768
Definition: nuklear.h:2037
#define NK_VECTOR_STACK_SIZE
Definition: nuklear.h:3914
Definition: nuklear.h:2842
Definition: nuklear.h:3004
struct nk_draw_null_texture null
Definition: nuklear.h:988
NK_API void nk_layout_row_dynamic(struct nk_context *ctx, float height, int cols)
Definition: nuklear.h:3249
NK_API int nk_strlen(const char *str)
struct nk_style_item normal
Definition: nuklear.h:3456
float height
Definition: nuklear.h:2365
unsigned short rounding
Definition: nuklear.h:2884
Definition: nuklear.h:692
struct nk_page * next
Definition: nuklear.h:3990
NK_API float nk_strtof(const char *str, const char **endptr)
NK_UINT32 nk_uint
Definition: nuklear.h:400
struct nk_vec2 spacing
Definition: nuklear.h:3560
#define NK_SIZE_TYPE
Definition: nuklear.h:374
struct nk_color bar_active
Definition: nuklear.h:3366
Definition: nuklear.h:2823
Definition: nuklear.h:3614
struct nk_color cursor_text_normal
Definition: nuklear.h:3465
NK_API struct nk_color nk_rgb_fv(const float *rgb)
NK_API int nk_window_is_collapsed(struct nk_context *ctx, const char *name)
int tree_depth
Definition: nuklear.h:3744
NK_API void nk_layout_row_template_begin(struct nk_context *, float height)
NK_API void nk_draw_text(struct nk_command_buffer *, struct nk_rect, const char *text, int len, const struct nk_user_font *, struct nk_color, struct nk_color)
float b
Definition: nuklear.h:454
enum nk_allocation_type type
Definition: nuklear.h:3996
struct nk_command header
Definition: nuklear.h:2965
unsigned int seq
Definition: nuklear.h:3845
struct nk_buffer memory
Definition: nuklear.h:4009
nk_text_align
Definition: nuklear.h:1741
NK_API struct nk_color nk_hsva_iv(const int *hsva)
NK_API void nk_combobox(struct nk_context *, const char **items, int count, int *selected, int item_height, struct nk_vec2 size)
struct nk_scroll scrollbar
Definition: nuklear.h:3826
NK_API void nk_buffer_reset(struct nk_buffer *, enum nk_buffer_allocation_type type)
NK_API int nk_str_insert_text_runes(struct nk_str *, int pos, const nk_rune *, int)
enum nk_symbol_type sym_maximize
Definition: nuklear.h:3575
NK_API void nk_textedit_delete_selection(struct nk_text_edit *)
struct nk_window * end
Definition: nuklear.h:4038
Definition: nuklear.h:680
Definition: nuklear.h:2032
struct nk_rect item
Definition: nuklear.h:3743
NK_API void nk_color_hsva_bv(nk_byte *hsva_out, struct nk_color)
NK_API int nk_group_scrolled_offset_begin(struct nk_context *, nk_uint *x_offset, nk_uint *y_offset, const char *, nk_flags)
float item_offset
Definition: nuklear.h:3741
Definition: nuklear.h:461
struct nk_color text
Definition: nuklear.h:3567
NK_API struct nk_color nk_rgba(int r, int g, int b, int a)
Definition: nuklear.h:2554
NK_API void * nk_buffer_memory(struct nk_buffer *)
nk_text_edit_type
Definition: nuklear.h:2714
NK_API void nk_textedit_init_fixed(struct nk_text_edit *, void *memory, nk_size size)
NK_API int nk_init_fixed(struct nk_context *, void *memory, nk_size size, const struct nk_user_font *)
unsigned short h
Definition: nuklear.h:2886
#define NK_SATURATE(x)
Definition: nuklear.h:4054
struct nk_style_slider slider
Definition: nuklear.h:3664
struct nk_color label_active
Definition: nuklear.h:3498
Definition: nuklear.h:2023
Definition: nuklear.h:3729
NK_API void nk_stroke_curve(struct nk_command_buffer *, float, float, float, float, float, float, float, float, float line_thickness, struct nk_color)
float popup_border
Definition: nuklear.h:3634
NK_API int nk_button_image(struct nk_context *, struct nk_image img)
NK_API struct nk_image nk_subimage_handle(nk_handle, unsigned short w, unsigned short h, struct nk_rect sub_region)
nk_hash name
Definition: nuklear.h:3819
float border
Definition: nuklear.h:3556
NK_API int nk_combo(struct nk_context *, const char **items, int count, int selected, int item_height, struct nk_vec2 size)
Definition: nuklear.h:3844
Definition: nuklear.h:2044
Definition: nuklear.h:1182
nk_byte a
Definition: nuklear.h:453
NK_API struct nk_color nk_rgba_f(float r, float g, float b, float a)
NK_API void nk_str_clear(struct nk_str *)
float rounding
Definition: nuklear.h:3528
float a[2]
Definition: nuklear.h:2945
#define NK_TEXTEDIT_UNDOCHARCOUNT
Definition: nuklear.h:2688
NK_API const void * nk_buffer_memory_const(const struct nk_buffer *)
#define nk_ptr_add_const(t, p, i)
Definition: nuklear.h:4071
Definition: nuklear.h:2837
NK_API void nk_buffer_init_fixed(struct nk_buffer *, void *memory, nk_size size)
float x
Definition: nuklear.h:457
Definition: nuklear.h:977
Definition: nuklear.h:2021
NK_API void nk_popup_close(struct nk_context *)
NK_API void nk_stroke_line(struct nk_command_buffer *b, float x0, float y0, float x1, float y1, float line_thickness, struct nk_color)
Definition: nuklear.h:2033
short x
Definition: nuklear.h:2995
nk_uint nk_rune
Definition: nuklear.h:406
struct nk_page_element * freelist
Definition: nuklear.h:3999
struct nk_window * next
Definition: nuklear.h:3867
NK_API struct nk_color nk_color_picker(struct nk_context *, struct nk_color, enum nk_color_format)
struct nk_vec2 combo_padding
Definition: nuklear.h:3644
NK_API int nk_str_append_text_utf8(struct nk_str *, const char *, int)
struct nk_color text_hover
Definition: nuklear.h:3304
NK_API void nk_text_colored(struct nk_context *, const char *, int, nk_flags, struct nk_color)
int end
Definition: nuklear.h:1680
struct nk_config_stack_flags flags
Definition: nuklear.h:3957
nk_panel_set
Definition: nuklear.h:3699
unsigned short w
Definition: nuklear.h:2996
float x
Definition: nuklear.h:3717
struct nk_image image
Definition: nuklear.h:3250
float cursor_rounding
Definition: nuklear.h:3412
NK_API int nk_checkbox_flags_text(struct nk_context *, const char *, int, unsigned int *flags, unsigned int value)
Definition: nuklear.h:3976
NK_API int nk_button_image_styled(struct nk_context *, const struct nk_style_button *, struct nk_image img)
unsigned short line_thickness
Definition: nuklear.h:2866
int total_height
Definition: nuklear.h:1682
NK_API struct nk_rect nk_rect(float x, float y, float w, float h)
Definition: nuklear.h:3798
nk_orientation
Definition: nuklear.h:468
NK_API void nk_style_show_cursor(struct nk_context *)
struct nk_color text_background
Definition: nuklear.h:3341
struct nk_window * prev
Definition: nuklear.h:3868
int cursor
Definition: nuklear.h:3823
struct nk_vec2 min_size
Definition: nuklear.h:3639
struct nk_command header
Definition: nuklear.h:2933
struct nk_color color
Definition: nuklear.h:2929
float spacing
Definition: nuklear.h:3312
Definition: nuklear.h:2824
nk_widget_layout_states
Definition: nuklear.h:1709
Definition: nuklear.h:2831
struct nk_style_scrollbar scrollv
Definition: nuklear.h:3670
NK_API void nk_chart_add_slot_colored(struct nk_context *ctx, const enum nk_chart_type, struct nk_color, struct nk_color active, int count, float min_value, float max_value)
enum nk_anti_aliasing line_AA
Definition: nuklear.h:983
nk_collapse_states
Definition: nuklear.h:469
short redo_point
Definition: nuklear.h:2709
NK_API const char * nk_utf_at(const char *buffer, int length, int index, nk_rune *unicode, int *len)
Definition: nuklear.h:499
Definition: nuklear.h:456
NK_API int nk_chart_begin_colored(struct nk_context *, enum nk_chart_type, struct nk_color, struct nk_color active, int num, float min, float max)
NK_API void nk_style_hide_cursor(struct nk_context *)
NK_API int nk_menu_begin_image_text(struct nk_context *, const char *, int, nk_flags align, struct nk_image, struct nk_vec2 size)
Definition: nuklear.h:3725
struct nk_color border_color
Definition: nuklear.h:3361
Definition: nuklear.h:1712
Definition: nuklear.h:2025
NK_API int nk_group_scrolled_begin(struct nk_context *, struct nk_scroll *, const char *title, nk_flags)
struct nk_color color
Definition: nuklear.h:2887
NK_API void nk_str_remove_runes(struct nk_str *str, int len)
struct nk_vec2 spacing
Definition: nuklear.h:3637
float item_width
Definition: nuklear.h:3739
Definition: nuklear.h:2826
Definition: nuklear.h:2050
Definition: nuklear.h:3356
#define NK_ALIGN_PTR(x, mask)
Definition: nuklear.h:4092
struct nk_color color
Definition: nuklear.h:2906
int cursor_visible
Definition: nuklear.h:3655
NK_API int nk_widget_has_mouse_click_down(struct nk_context *, enum nk_buttons, int down)
#define NK_CLAMP(i, v, x)
Definition: nuklear.h:317
struct nk_style_combo combo
Definition: nuklear.h:3672
struct nk_style_property property
Definition: nuklear.h:3666
unsigned short region[4]
Definition: nuklear.h:461
NK_API void nk_input_begin(struct nk_context *)
int length
Definition: nuklear.h:3834
struct nk_color contextual_border_color
Definition: nuklear.h:3622
Definition: nuklear.h:2909
NK_API int nk_option_text(struct nk_context *, const char *, int, int active)
void * ptr
Definition: nuklear.h:460
struct nk_menu_state menu
Definition: nuklear.h:3773
NK_API void nk_stroke_rect(struct nk_command_buffer *, struct nk_rect, float rounding, float line_thickness, struct nk_color)
NK_API int nk_menu_begin_symbol_text(struct nk_context *, const char *, int, nk_flags align, enum nk_symbol_type, struct nk_vec2 size)
NK_API void nk_push_scissor(struct nk_command_buffer *, struct nk_rect)
NK_API const struct nk_command * nk__begin(struct nk_context *)
NK_API nk_flags nk_chart_push_slot(struct nk_context *, float, int)
Definition: nuklear.h:2028
nk_edit_flags
Definition: nuklear.h:1877
#define NK_INBOX(px, py, x, y, w, h)
Definition: nuklear.h:4058
int value
Definition: der_length_ia5_string.c:21
#define nk_vec2_sub(a, b)
Definition: nuklear.h:4065
Definition: nuklear.h:470
NK_API int nk_str_append_str_char(struct nk_str *, const char *)
float indent
Definition: nuklear.h:3580
Definition: nuklear.h:700
struct nk_color selected_color
Definition: nuklear.h:3523
unsigned char initialized
Definition: nuklear.h:2736
Definition: nuklear.h:2029
Definition: nuklear.h:1180
NK_API int nk_input_is_key_down(const struct nk_input *, enum nk_keys)
Definition: nuklear.h:501
NK_API int nk_window_is_hovered(struct nk_context *)
short x
Definition: nuklear.h:2974
NK_API double nk_propertyd(struct nk_context *, const char *name, double min, double val, double max, double step, float inc_per_pixel)
#define NK_PI
Definition: nuklear.h:4049
struct nk_cursor * cursor_last
Definition: nuklear.h:3654
nk_size last
Definition: nuklear.h:3012
NK_API int nk_filter_decimal(const struct nk_text_edit *, nk_rune unicode)
Definition: nuklear.h:1899
Definition: nuklear.h:469
float height
Definition: nuklear.h:2997
NK_API int nk_filter_binary(const struct nk_text_edit *, nk_rune unicode)
NK_API int nk_init(struct nk_context *, struct nk_allocator *, const struct nk_user_font *)
Definition: nuklear.h:2030
NK_API int nk_radio_label(struct nk_context *, const char *, int *active)
NK_API void nk_contextual_close(struct nk_context *)
short y
Definition: nuklear.h:2919
NK_API int nk_input_has_mouse_click_in_rect(const struct nk_input *, enum nk_buttons, struct nk_rect)
void(* nk_command_custom_callback)(void *canvas, short x, short y, unsigned short w, unsigned short h, nk_handle callback_data)
Definition: nuklear.h:2980
NK_API void nk_textedit_init(struct nk_text_edit *, struct nk_allocator *, nk_size size)
const struct nk_cursor * cursors[NK_CURSOR_COUNT]
Definition: nuklear.h:3652
struct nk_vec2 spacing
Definition: nuklear.h:3379
const struct nk_draw_vertex_layout_element * vertex_layout
Definition: nuklear.h:989
struct nk_style_chart chart
Definition: nuklear.h:3668
#define NK_UTF_SIZE
Definition: nuklear.h:255
struct nk_vec2 popup_padding
Definition: nuklear.h:3643
NK_API void nk_layout_row_begin(struct nk_context *ctx, enum nk_layout_format fmt, float row_height, int cols)
short delete_length
Definition: nuklear.h:2701
NK_API void nk_fill_arc(struct nk_command_buffer *, float cx, float cy, float radius, float a_min, float a_max, struct nk_color)
NK_API const char * nk_str_get_const(const struct nk_str *)
NK_API int nk_textedit_cut(struct nk_text_edit *)
Definition: nuklear.h:972
NK_API void nk_property_double(struct nk_context *, const char *name, double min, double *val, double max, double step, float inc_per_pixel)
Definition: nuklear.h:3563
struct nk_color cursor_text_hover
Definition: nuklear.h:3466
NK_API int nk_button_image_label_styled(struct nk_context *, const struct nk_style_button *, struct nk_image img, const char *, nk_flags text_alignment)
NK_API int nk_combo_separator(struct nk_context *, const char *items_separated_by_separator, int separator, int selected, int count, int item_height, struct nk_vec2 size)
NK_API void nk_color_hsva_i(int *h, int *s, int *v, int *a, struct nk_color)
float rounding
Definition: nuklear.h:3376
NK_API void nk_stroke_polyline(struct nk_command_buffer *, float *points, int point_count, float line_thickness, struct nk_color col)
NK_API void nk_text_wrap_colored(struct nk_context *, const char *, int, struct nk_color)
NK_API enum nk_widget_layout_states nk_widget(struct nk_rect *, const struct nk_context *)
nk_edit_events
Definition: nuklear.h:1898
NK_API struct nk_vec2 nk_rect_pos(struct nk_rect)
Definition: nuklear.h:3724
struct nk_text_undo_state undo
Definition: nuklear.h:2742
NK_API int nk_input_is_mouse_released(const struct nk_input *, enum nk_buttons)
Definition: nuklear.h:2038
NK_API void nk_property_int(struct nk_context *, const char *name, int min, int *val, int max, int step, float inc_per_pixel)
struct nk_style_button button
Definition: nuklear.h:3550
#define NK_SCROLLBAR_HIDING_TIMEOUT
Definition: nuklear.h:263
enum nk_symbol_type sym_right
Definition: nuklear.h:3502
Definition: nuklear.h:3650
NK_API void nk_color_hex_rgba(char *output, struct nk_color)
#define NK_MIN(a, b)
Definition: nuklear.h:315
Definition: nuklear.h:3792
struct nk_vec2 group_padding
Definition: nuklear.h:3642
Definition: nuklear.h:468
nk_handle userdata
Definition: nuklear.h:485
NK_API void nk_style_load_cursor(struct nk_context *, enum nk_style_cursor, const struct nk_cursor *)
unsigned int size
Definition: nuklear.h:3989
Definition: nuklear.h:455
Definition: nuklear.h:457
NK_API int nk_input_is_mouse_pressed(const struct nk_input *, enum nk_buttons)
Definition: nuklear.h:2039
struct nk_style_item cursor_normal
Definition: nuklear.h:3370
#define NK_VALUE_PAGE_CAPACITY
Definition: nuklear.h:3966
Definition: nuklear.h:474
NK_API void nk_push_custom(struct nk_command_buffer *, struct nk_rect, nk_command_custom_callback, nk_handle usr)
Definition: nuklear.h:2957
Definition: nuklear.h:490
NK_API int nk_str_len_char(struct nk_str *)
int active
Definition: nuklear.h:2558
Definition: nuklear.h:2053
unsigned int clicked
Definition: nuklear.h:3062
NK_API int nk_input_any_mouse_click_in_rect(const struct nk_input *, struct nk_rect)
void * ptr
Definition: nuklear.h:2562
Definition: nuklear.h:2024
NK_API const char * nk_style_get_color_by_name(enum nk_style_colors)
void(* nk_query_font_glyph_f)(nk_handle handle, float font_height, struct nk_user_font_glyph *glyph, nk_rune codepoint, nk_rune next_codepoint)
Definition: nuklear.h:2345
Definition: nuklear.h:3728
NK_API void nk_stroke_arc(struct nk_command_buffer *, float cx, float cy, float radius, float a_min, float a_max, float line_thickness, struct nk_color)
Definition: nuklear.h:975
Definition: nuklear.h:2705
Definition: nuklear.h:662
nk_size vertex_alignment
Definition: nuklear.h:991
NK_API void nk_tooltip_end(struct nk_context *)
Definition: nuklear.h:679
Definition: nuklear.h:502
struct nk_color border_color
Definition: nuklear.h:3522
struct nk_style_item cursor_normal
Definition: nuklear.h:3403
unsigned short h
Definition: nuklear.h:2921
Definition: nuklear.h:1901
Definition: nuklear.h:503
short w
Definition: nuklear.h:458
NK_API void nk_spacing(struct nk_context *, int cols)
Definition: nuklear.h:467
Definition: nuklear.h:2537
Definition: nuklear.h:682
float y
Definition: nuklear.h:455
NK_API struct nk_color nk_rgba_hex(const char *rgb)
struct nk_vec2i points[1]
Definition: nuklear.h:2961
struct nk_vec2 padding
Definition: nuklear.h:3581
struct nk_command header
Definition: nuklear.h:2958
struct nk_style_item active
Definition: nuklear.h:3492
GLuint texture
Definition: sdl2backend.cpp:527
NK_API int nk_button_symbol_label(struct nk_context *, enum nk_symbol_type, const char *, nk_flags text_alignment)
#define NK_STATIC_ASSERT(exp)
Definition: nuklear.h:304
NK_API struct nk_image nk_subimage_ptr(void *, unsigned short w, unsigned short h, struct nk_rect sub_region)
NK_API void nk_text_wrap(struct nk_context *, const char *, int)
NK_API struct nk_image nk_image_handle(nk_handle)
NK_API struct nk_image nk_image_ptr(void *)
short y
Definition: nuklear.h:2927
NK_API float nk_window_get_width(const struct nk_context *)
NK_API int nk_image_is_subimage(const struct nk_image *img)
nk_size begin
Definition: nuklear.h:3012
struct nk_command header
Definition: nuklear.h:2883
Definition: nuklear.h:973
Definition: nuklear.h:1179
NK_API int nk_style_push_font(struct nk_context *, struct nk_user_font *)
struct nk_context * ctx
Definition: nuklear.h:1683
unsigned char mode
Definition: nuklear.h:2734
struct nk_style_item hover
Definition: nuklear.h:3359
unsigned short h
Definition: nuklear.h:2996
NK_API void nk_draw_image(struct nk_command_buffer *, struct nk_rect, const struct nk_image *, struct nk_color)
struct nk_color text_hover_active
Definition: nuklear.h:3339
NK_API int nk_selectable_label(struct nk_context *, const char *, nk_flags align, int *value)
struct nk_style_button tab_minimize_button
Definition: nuklear.h:3571
struct nk_vec2 padding
Definition: nuklear.h:3484
NK_API struct nk_color nk_hsva(int h, int s, int v, int a)
struct nk_vec2 spacing
Definition: nuklear.h:3582
#define NK_STYLE_ITEM_STACK_SIZE
Definition: nuklear.h:3906
Definition: nuklear.h:669
NK_API int nk_str_insert_text_utf8(struct nk_str *, int pos, const char *, int)
NK_API void nk_tooltip(struct nk_context *, const char *)
Definition: nuklear.h:2563
struct nk_color text_active
Definition: nuklear.h:3305
#define NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS
Definition: nuklear.h:3684
nk_plugin_alloc alloc
Definition: nuklear.h:486
NK_API void nk_combo_close(struct nk_context *)
struct nk_color text_hover
Definition: nuklear.h:3470
NK_API int nk_radio_text(struct nk_context *, const char *, int, int *active)
NK_API void nk_buffer_clear(struct nk_buffer *)
Definition: nuklear.h:3761
nk_uint scroll_value
Definition: nuklear.h:1685
short undo_char_point
Definition: nuklear.h:2710
enum nk_symbol_type sym_hover
Definition: nuklear.h:3552
int id
Definition: nuklear.h:460
Definition: nuklear.h:2362
NK_API struct nk_vec2 nk_window_get_size(const struct nk_context *)
Definition: nuklear.h:465
nk_uint * offset_y
Definition: nuklear.h:3766
struct nk_command header
Definition: nuklear.h:2950
struct nk_color label_hover
Definition: nuklear.h:3497
Definition: nuklear.h:1717
int select_end
Definition: nuklear.h:2733
NK_API const char * nk_str_at_char_const(const struct nk_str *, int pos)
struct nk_configuration_stacks stacks
Definition: nuklear.h:4013
Definition: nuklear.h:1900
Definition: nuklear.h:2900
NK_API nk_handle nk_handle_id(int)
NK_API int nk_combo_item_image_label(struct nk_context *, struct nk_image, const char *, nk_flags alignment)
unsigned short h
Definition: nuklear.h:2893
NK_UINT8 nk_uchar
Definition: nuklear.h:395
int active
Definition: nuklear.h:3822
NK_API struct nk_color nk_rgb_f(float r, float g, float b)
Definition: nuklear.h:2721
enum nk_allocation_type type
Definition: nuklear.h:2568
float r
Definition: nuklear.h:454
nk_window_flags
Definition: nuklear.h:3788
short x
Definition: nuklear.h:2892
nk_chart_type
Definition: nuklear.h:471
float x
Definition: nuklear.h:455
struct nk_color symbol_hover
Definition: nuklear.h:3546
enum nk_chart_type type
Definition: nuklear.h:3706
Definition: nuklear.h:498
struct nk_rect bounds
Definition: nuklear.h:3764
Definition: nuklear.h:2018
Definition: nuklear.h:2548
NK_API int nk_contextual_item_label(struct nk_context *, const char *, nk_flags align)
#define NK_CONFIGURATION_STACK_TYPE(prefix, name, type)
Definition: nuklear.h:3925
NK_API int nk_list_view_begin(struct nk_context *, struct nk_list_view *out, const char *id, nk_flags, int row_height, int row_count)
float rounding
Definition: nuklear.h:3481
nk_size size
Definition: nuklear.h:4001
struct nk_vec2 padding
Definition: nuklear.h:3346
NK_API void nk_stroke_polygon(struct nk_command_buffer *, float *, int point_count, float line_thickness, struct nk_color)
NK_API void nk_popup_end(struct nk_context *)
int build
Definition: nuklear.h:4034
struct nk_page * pages
Definition: nuklear.h:3998
NK_API void nk_input_motion(struct nk_context *, int x, int y)
NK_API int nk_textedit_paste(struct nk_text_edit *, char const *, int len)
Definition: nuklear.h:3321
NK_API int nk_color_pick(struct nk_context *, struct nk_color *, enum nk_color_format)
Definition: nuklear.h:2829
NK_API int nk_utf_len(const char *, int byte_len)
float g
Definition: nuklear.h:454
Definition: nuklear.h:974
NK_API void nk_triangle_from_direction(struct nk_vec2 *result, struct nk_rect r, float pad_x, float pad_y, enum nk_heading)
Definition: nuklear.h:1716
nk_size vertex_size
Definition: nuklear.h:990
unsigned short w
Definition: nuklear.h:2921
Definition: nuklear.h:1720
NK_API struct nk_color nk_hsva_fv(const float *hsva)
Definition: nuklear.h:462
Definition: nuklear.h:696
nk_size cap
Definition: nuklear.h:4002
Definition: nuklear.h:1884
Definition: nuklear.h:1176
enum nk_symbol_type inc_symbol
Definition: nuklear.h:3386
NK_API void nk_color_hsva_b(nk_byte *h, nk_byte *s, nk_byte *v, nk_byte *a, struct nk_color)
Definition: nuklear.h:3988
unsigned short rounding
Definition: nuklear.h:2875
void(* draw_end)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:3353
#define NK_UINT16
Definition: nuklear.h:346
Definition: nuklear.h:475
unsigned short w
Definition: nuklear.h:461
Definition: nuklear.h:2925
unsigned short w
Definition: nuklear.h:2928
#define NK_TEXTEDIT_UNDOSTATECOUNT
Definition: nuklear.h:2684
void(* draw_end)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:3516
NK_API void nk_chart_add_slot(struct nk_context *ctx, const enum nk_chart_type, int count, float min_value, float max_value)
struct nk_style_scrollbar scrollbar
Definition: nuklear.h:3460
struct nk_color bar_normal
Definition: nuklear.h:3364
nk_flags last_widget_state
Definition: nuklear.h:4011
Definition: nuklear.h:3802
#define nk_foreach(c, ctx)
Definition: nuklear.h:1011
struct nk_color color
Definition: nuklear.h:3707
struct nk_command header
Definition: nuklear.h:2926
int(* nk_plugin_filter)(const struct nk_text_edit *, nk_rune unicode)
Definition: nuklear.h:480
struct nk_style_item normal_active
Definition: nuklear.h:3328
Definition: nuklear.h:476
NK_API float nk_window_get_height(const struct nk_context *)
NK_API float nk_widget_height(struct nk_context *)
NK_API int nk_menu_item_image_label(struct nk_context *, struct nk_image, const char *, nk_flags alignment)
NK_API int nk_slide_int(struct nk_context *, int min, int val, int max, int step)
Definition: nuklear.h:3733
NK_API int nk_filter_oct(const struct nk_text_edit *, nk_rune unicode)
float filled
Definition: nuklear.h:3742
#define NK_LEN(a)
Definition: nuklear.h:4055
NK_API struct nk_rect nk_recta(struct nk_vec2 pos, struct nk_vec2 size)
Definition: nuklear.h:2828
Definition: nuklear.h:2990
Definition: nuklear.h:693
NK_API int nk_slider_float(struct nk_context *, float min, float *val, float max, float step)
NK_API int nk_window_is_hidden(struct nk_context *, const char *)
NK_API void nk_fill_triangle(struct nk_command_buffer *, float x0, float y0, float x1, float y1, float x2, float y2, struct nk_color)
Definition: nuklear.h:1880
short cx
Definition: nuklear.h:2934
#define NK_INTERN
Definition: nuklear.h:286
struct nk_command_buffer buffer
Definition: nuklear.h:3852
NK_API int nk_slider_int(struct nk_context *, int min, int *val, int max, int step)
nk_size allocated
Definition: nuklear.h:2541
nk_hash name
Definition: nuklear.h:3838
Definition: nuklear.h:468
struct nk_vec2i end
Definition: nuklear.h:2860
NK_API int nk_contextual_item_image_label(struct nk_context *, struct nk_image, const char *, nk_flags alignment)
NK_API void nk_input_button(struct nk_context *, enum nk_buttons, int x, int y, int down)
NK_API int nk_item_is_any_active(struct nk_context *)
NK_API void nk_label_colored_wrap(struct nk_context *, const char *, struct nk_color)
struct nk_style_toggle checkbox
Definition: nuklear.h:3662
NK_API void nk_input_key(struct nk_context *, enum nk_keys, int down)
NK_API struct nk_style_item nk_style_item_color(struct nk_color)
Definition: nuklear.h:2850
#define SEEK_SET
Definition: zconf.h:388
Definition: nuklear.h:677
NK_API void nk_fill_rect(struct nk_command_buffer *, struct nk_rect, float rounding, struct nk_color)
NK_API int nk_button_push_behavior(struct nk_context *, enum nk_button_behavior)
unsigned short table_count
Definition: nuklear.h:3863
#define nk_ptr_add(t, p, i)
Definition: nuklear.h:4070
NK_API float nk_slide_float(struct nk_context *, float min, float val, float max, float step)
NK_API void nk_color_hsva_fv(float *hsva_out, struct nk_color)
Definition: nuklear.h:667
NK_API void nk_fill_polygon(struct nk_command_buffer *, float *, int point_count, struct nk_color)
nk_size size
Definition: nuklear.h:2562
short x
Definition: nuklear.h:2877
NK_API float nk_widget_width(struct nk_context *)
struct nk_color border_color
Definition: nuklear.h:3400
Definition: nuklear.h:1747
Definition: nuklear.h:3532
#define nk_vec2_add(a, b)
Definition: nuklear.h:4066
NK_API int nk_input_is_mouse_hovering_rect(const struct nk_input *, struct nk_rect)
float cursor_border
Definition: nuklear.h:3411
NK_API int nk_chart_begin(struct nk_context *, enum nk_chart_type, int num, float min, float max)
NK_API int nk_style_pop_vec2(struct nk_context *)
Definition: nuklear.h:2054
struct nk_config_stack_style_item style_items
Definition: nuklear.h:3954
NK_API nk_size nk_buffer_total(struct nk_buffer *)
nk_size size
Definition: nuklear.h:2540
Definition: nuklear.h:681
NK_API nk_handle nk_handle_ptr(void *)
unsigned short h
Definition: nuklear.h:2985
struct nk_style_item cursor_active
Definition: nuklear.h:3372
NK_API void nk_window_show(struct nk_context *, const char *name, enum nk_show_states)
struct nk_style style
Definition: nuklear.h:4008
Definition: nuklear.h:1752
NK_API void nk_tree_pop(struct nk_context *)
float range
Definition: nuklear.h:3709
const struct nk_user_font * font
Definition: nuklear.h:2992
Definition: gtest_output_test_.cc:544
NK_API void nk_textedit_undo(struct nk_text_edit *)
NK_API unsigned nk_check_flags_text(struct nk_context *, const char *, int, unsigned int flags, unsigned int value)
unsigned int count
Definition: nuklear.h:4042
struct nk_popup_state popup
Definition: nuklear.h:3858
NK_API float nk_layout_ratio_from_pixel(struct nk_context *, float pixel_width)
Definition: nuklear.h:1750
NK_API nk_flags nk_edit_buffer(struct nk_context *, nk_flags, struct nk_text_edit *, nk_plugin_filter)
float y
Definition: nuklear.h:457
short x
Definition: nuklear.h:456
struct nk_color right
Definition: nuklear.h:2897
Definition: nuklear.h:3696
NK_API int nk_style_pop_style_item(struct nk_context *)
nk_handle userdata
Definition: nuklear.h:2363
Definition: nuklear.h:497
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len)
Definition: adler32.c:60
nk_plugin_filter filter
Definition: nuklear.h:2728
void(* draw_begin)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:3417
NK_API int nk_checkbox_flags_label(struct nk_context *, const char *, unsigned int *flags, unsigned int value)
struct nk_color symbol_active
Definition: nuklear.h:3547
nk_rune undo_char[NK_TEXTEDIT_UNDOCHARCOUNT]
Definition: nuklear.h:2707
float scrollbar_hiding_timer
Definition: nuklear.h:3854
NK_API int nk_str_append_str_utf8(struct nk_str *, const char *)
nk_text_alignment
Definition: nuklear.h:1749
Definition: nuklear.h:2822
#define NK_API
Definition: nuklear.h:282
struct nk_rect bounds
Definition: nuklear.h:3850
Definition: nuklear.h:2715
unsigned short w
Definition: nuklear.h:2985
NK_API int nk_window_is_active(struct nk_context *, const char *)
Definition: nuklear.h:471
unsigned short line_thickness
Definition: nuklear.h:2920
Definition: nuklear.h:466
struct nk_style_window_header header
Definition: nuklear.h:3615
Definition: nuklear.h:3587
float global_alpha
Definition: nuklear.h:982
struct nk_command header
Definition: nuklear.h:2891
Definition: nuklear.h:2982
struct nk_color color
Definition: nuklear.h:2879
Definition: nuklear.h:470
unsigned capacity
Definition: nuklear.h:4000
NK_API int nk_style_push_color(struct nk_context *, struct nk_color *, struct nk_color)
struct nk_vec2 padding
Definition: nuklear.h:3529
Definition: nuklear.h:1887
NK_API void nk_style_load_all_cursors(struct nk_context *, struct nk_cursor *)
struct nk_vec2 touch_padding
Definition: nuklear.h:3347
struct nk_color color
Definition: nuklear.h:2951
struct nk_style_item fixed_background
Definition: nuklear.h:3616
Definition: nuklear.h:2020
nk_byte b
Definition: nuklear.h:453
NK_API int nk_input_has_mouse_click(const struct nk_input *, enum nk_buttons)
NK_API int nk_combo_begin_color(struct nk_context *, struct nk_color color, struct nk_vec2 size)
NK_API void nk_str_free(struct nk_str *)
int show_buttons
Definition: nuklear.h:3383
NK_API int nk_option_label(struct nk_context *, const char *, int active)
float border
Definition: nuklear.h:3410
nk_allocation_type
Definition: nuklear.h:2546
void(* nk_plugin_free)(nk_handle, void *old)
Definition: nuklear.h:479
struct nk_vec2i a
Definition: nuklear.h:2911
nk_plugin_paste paste
Definition: nuklear.h:2694
NK_API int nk_combo_begin_image_label(struct nk_context *, const char *selected, struct nk_image, struct nk_vec2 size)
nk_size next
Definition: nuklear.h:2844
struct nk_color color
Definition: nuklear.h:2959
struct nk_style_item background
Definition: nuklear.h:3565
Definition: nuklear.h:2035
NK_API void nk_textedit_free(struct nk_text_edit *)
struct nk_scroll scrollbar
Definition: nuklear.h:3851
NK_API void nk_color_hsva_iv(int *hsva_out, struct nk_color)
struct nk_buffer * base
Definition: nuklear.h:3008
float(* nk_text_width_f)(nk_handle, float h, const char *, int len)
Definition: nuklear.h:2344
int use_clipping
Definition: nuklear.h:3010
NK_API struct nk_command_buffer * nk_window_get_canvas(struct nk_context *)
NK_API int nk_checkbox_text(struct nk_context *, const char *, int, int *active)
nk_uint nk_hash
Definition: nuklear.h:404
NK_API int nk_str_len(struct nk_str *)
nk_command_type
Definition: nuklear.h:2819
NK_API nk_flags nk_edit_string(struct nk_context *, nk_flags, char *buffer, int *len, int max, nk_plugin_filter)
NK_API void nk_edit_unfocus(struct nk_context *)
unsigned int old
Definition: nuklear.h:3821
nk_size calls
Definition: nuklear.h:2543
Definition: nuklear.h:686
Definition: nuklear.h:1746
struct nk_vec2 pos
Definition: nuklear.h:3051
Definition: nuklear.h:2552
struct nk_style_item hover
Definition: nuklear.h:3491
Definition: nuklear.h:684
NK_API int nk_combo_item_image_text(struct nk_context *, struct nk_image, const char *, int, nk_flags alignment)
NK_API int nk_combo_begin_symbol_text(struct nk_context *, const char *selected, int, enum nk_symbol_type, struct nk_vec2 size)
Definition: nuklear.h:2046
#define NK_INPUT_MAX
Definition: nuklear.h:257
NK_API int nk_menu_begin_symbol_label(struct nk_context *, const char *, nk_flags align, enum nk_symbol_type, struct nk_vec2 size)
Definition: nuklear.h:1894
NK_API void nk_buffer_free(struct nk_buffer *)
Definition: nuklear.h:2832
NK_API struct nk_color nk_hsv_f(float h, float s, float v)
nk_hash name
Definition: nuklear.h:3846
struct nk_style_item cursor_active
Definition: nuklear.h:3405
struct nk_color color
Definition: nuklear.h:2922
struct nk_style_item normal
Definition: nuklear.h:3358
NK_API int nk_button_symbol(struct nk_context *, enum nk_symbol_type)
NK_API int nk_checkbox_label(struct nk_context *, const char *, int *active)
int use_pool
Definition: nuklear.h:4035
struct nk_vec2 scroll_delta
Definition: nuklear.h:3054
NK_API int nk_window_is_closed(struct nk_context *, const char *)
struct nk_vec2 padding
Definition: nuklear.h:3310
Definition: nuklear.h:469
Definition: nuklear.h:685
NK_API int nk_group_begin(struct nk_context *, const char *title, nk_flags)
Definition: nuklear.h:2972
Definition: nuklear.h:2917
NK_API void nk_buffer_info(struct nk_memory_status *, struct nk_buffer *)
NK_API const char * nk_str_at_const(const struct nk_str *, int pos, nk_rune *unicode, int *len)
struct nk_color symbol_normal
Definition: nuklear.h:3545
struct nk_vec2 delta
Definition: nuklear.h:3053
Definition: nuklear.h:3953
#define NK_COLOR_STACK_SIZE
Definition: nuklear.h:3922
float row_padding
Definition: nuklear.h:3485
struct nk_style_item normal
Definition: nuklear.h:3293
enum nk_panel_row_layout_type type
Definition: nuklear.h:3734
NK_API void nk_color_hsv_i(int *out_h, int *out_s, int *out_v, struct nk_color)
Definition: nuklear.h:981
#define NK_BETWEEN(x, a, b)
Definition: nuklear.h:4057
NK_API struct nk_rect nk_window_get_bounds(const struct nk_context *ctx)
NK_API void nk_clear(struct nk_context *)
struct nk_color cursor_border_color
Definition: nuklear.h:3406
Definition: nuklear.h:2022
Definition: nuklear.h:674
float w
Definition: nuklear.h:457
struct nk_color border_color
Definition: nuklear.h:3493
NK_API void nk_menu_end(struct nk_context *)
#define NK_CONTAINER_OF(ptr, type, member)
Definition: nuklear.h:4098
struct nk_style_item hover
Definition: nuklear.h:3324
NK_API int nk_selectable_image_text(struct nk_context *, struct nk_image, const char *, int, nk_flags align, int *value)
NK_API nk_flags nk_chart_push(struct nk_context *, float)
NK_API unsigned nk_check_flags_label(struct nk_context *, const char *, unsigned int flags, unsigned int value)
float rounding
Definition: nuklear.h:3345
NK_API int nk_begin_titled(struct nk_context *ctx, const char *name, const char *title, struct nk_rect bounds, nk_flags flags)
NK_API float nk_propertyf(struct nk_context *, const char *name, float min, float val, float max, float step, float inc_per_pixel)
NK_API int nk_input_is_key_released(const struct nk_input *, enum nk_keys)
Definition: nuklear.h:495
struct nk_color cursor_hover
Definition: nuklear.h:3464
struct nk_style_item hover
Definition: nuklear.h:3398
Definition: nuklear.h:2864
Definition: nuklear.h:2949
enum nk_command_type type
Definition: nuklear.h:2843
float rounding
Definition: nuklear.h:3557
struct nk_color text_active
Definition: nuklear.h:3471
NK_API struct nk_rect nk_widget_bounds(struct nk_context *)
struct nk_config_stack_vec2 vectors
Definition: nuklear.h:3956
float border
Definition: nuklear.h:3578
Definition: nuklear.h:473
Definition: nuklear.h:2825
short y
Definition: nuklear.h:2852
NK_API void nk_window_show_if(struct nk_context *, const char *name, enum nk_show_states, int cond)
NK_API int nk_tree_image_push_hashed(struct nk_context *, enum nk_tree_type, struct nk_image, const char *title, enum nk_collapse_states initial_state, const char *hash, int len, int seed)
nk_color_format
Definition: nuklear.h:473
struct nk_command header
Definition: nuklear.h:2991
float combo_border
Definition: nuklear.h:3629
struct nk_color cursor_normal
Definition: nuklear.h:3463
struct nk_command header
Definition: nuklear.h:2983
nk_hash keys[NK_VALUE_PAGE_CAPACITY]
Definition: nuklear.h:3971
NK_API struct nk_color nk_hsv_iv(const int *hsv)
NK_API int nk_menu_begin_image(struct nk_context *, const char *, struct nk_image, struct nk_vec2 size)
struct nk_color popup_border_color
Definition: nuklear.h:3620
NK_API int nk_menu_begin_image_label(struct nk_context *, const char *, nk_flags align, struct nk_image, struct nk_vec2 size)
Definition: nuklear.h:3982
NK_API int nk_str_insert_at_char(struct nk_str *, int pos, const char *, int)
Definition: nuklear.h:1711
Definition: nuklear.h:2692
NK_API int nk_selectable_text(struct nk_context *, const char *, int, nk_flags align, int *value)
NK_UINT16 nk_ushort
Definition: nuklear.h:398
Definition: nuklear.h:2964
Definition: nuklear.h:1743
Definition: nuklear.h:3796
unsigned int old
Definition: nuklear.h:3840
nk_size size
Definition: nuklear.h:2580
enum nk_panel_type type
Definition: nuklear.h:3762
NK_API int nk_input_is_mouse_down(const struct nk_input *, enum nk_buttons)
NK_API nk_size nk_prog(struct nk_context *, nk_size cur, nk_size max, int modifyable)
NK_API int nk_filter_float(const struct nk_text_edit *, nk_rune unicode)
struct nk_vec2i begin
Definition: nuklear.h:2867
Definition: nuklear.h:3790
nk_handle callback_data
Definition: nuklear.h:2986
NK_API void nk_input_end(struct nk_context *)
NK_API int nk_button_pop_behavior(struct nk_context *)
float h
Definition: nuklear.h:457
struct nk_color selected_normal
Definition: nuklear.h:3474
NK_API void nk_layout_row(struct nk_context *, enum nk_layout_format, float height, int cols, const float *ratio)
NK_API void nk_layout_row_template_end(struct nk_context *)
Definition: nuklear.h:2043
Definition: nuklear.h:1721
float rounding
Definition: nuklear.h:3636
void(* draw_end)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:3392
NK_API struct nk_color nk_hsva_f(float h, float s, float v, float a)
struct nk_style_edit edit
Definition: nuklear.h:3509
NK_API int nk_combo_string(struct nk_context *, const char *items_separated_by_zeros, int selected, int count, int item_height, struct nk_vec2 size)
struct nk_style_toggle option
Definition: nuklear.h:3661
struct nk_panel pan
Definition: nuklear.h:3978
Definition: nuklear.h:678
NK_API int nk_strmatch_fuzzy_string(char const *str, char const *pattern, int *out_score)
struct nk_buffer_marker marker[NK_BUFFER_MAX]
Definition: nuklear.h:2564
NK_API int nk_combo_begin_image_text(struct nk_context *, const char *selected, int, struct nk_image, struct nk_vec2 size)
Definition: nuklear.h:2835
Definition: nuklear.h:2036
char string[1]
Definition: nuklear.h:2999
Definition: nuklear.h:2049
int heuristic(Location a, Location b)
Definition: findpath.cpp:58
nk_plugin_copy copy
Definition: nuklear.h:2695
Definition: nuklear.h:3259
struct nk_vec2 size offset
Definition: nuklear.h:462
struct nk_style_item normal
Definition: nuklear.h:3397
NK_API int nk_selectable_image_label(struct nk_context *, struct nk_image, const char *, nk_flags align, int *value)
Definition: nuklear.h:666
struct nk_style_button node_minimize_button
Definition: nuklear.h:3573
Definition: nuklear.h:3731
unsigned short line_thickness
Definition: nuklear.h:2936
NK_API int nk_check_text(struct nk_context *, const char *, int, int active)
short y
Definition: nuklear.h:2995
struct nk_text_edit text_edit
Definition: nuklear.h:4029
NK_API int nk_style_push_style_item(struct nk_context *, struct nk_style_item *, struct nk_style_item)
Definition: nuklear.h:2051
NK_API void nk_textedit_delete(struct nk_text_edit *, int where, int len)
int slot
Definition: nuklear.h:3716
NK_API nk_hash nk_murmur_hash(const void *key, int len, nk_hash seed)
struct nk_style_item active
Definition: nuklear.h:3295
char name_string[NK_WINDOW_MAX_NAME]
Definition: nuklear.h:3847
Definition: nuklear.h:4005
typedef int(ENET_CALLBACK *ENetInterceptCallback)(struct _ENetHost *host
Definition: nuklear.h:2856
struct nk_page_element * prev
Definition: nuklear.h:3985
short x
Definition: nuklear.h:458
enum nk_anti_aliasing shape_AA
Definition: nuklear.h:984
Definition: nuklear.h:1710
struct nk_rect clip
Definition: nuklear.h:3009
struct nk_panel * layout
Definition: nuklear.h:3853
int length
Definition: nuklear.h:2998
NK_API void nk_style_set_font(struct nk_context *, const struct nk_user_font *)
struct nk_color left
Definition: nuklear.h:2894
Definition: nuklear.h:2873
struct nk_str string
Definition: nuklear.h:2727
nk_handle userdata
Definition: nuklear.h:3514
Definition: nuklear.h:466
Definition: nuklear.h:1885
#define const
Definition: zconf.h:196
short char_storage
Definition: nuklear.h:2702
short redo_char_point
Definition: nuklear.h:2711
int sel_start
Definition: nuklear.h:3824
struct nk_command header
Definition: nuklear.h:2865
short x
Definition: nuklear.h:2984
struct nk_clipboard clip
Definition: nuklear.h:4010
NK_API void nk_color_hsv_b(nk_byte *out_h, nk_byte *out_s, nk_byte *out_v, struct nk_color)
struct nk_vec2 content_padding
Definition: nuklear.h:3558
unsigned short line_thickness
Definition: nuklear.h:2876
enum nk_style_item_type type
Definition: nuklear.h:3255
NK_API void nk_label_colored(struct nk_context *, const char *, nk_flags align, struct nk_color)
Definition: nuklear.h:3831
Definition: nuklear.h:471
struct nk_color text_normal
Definition: nuklear.h:3303
Definition: nuklear.h:690
struct nk_color label_hover
Definition: nuklear.h:3541
Definition: nuklear.h:2045
NK_API int nk_check_label(struct nk_context *, const char *, int active)
struct nk_command header
Definition: nuklear.h:2942
NK_API void nk_window_set_bounds(struct nk_context *, struct nk_rect bounds)
nk_layout_format
Definition: nuklear.h:475
struct nk_color bar_filled
Definition: nuklear.h:3367
Definition: nuklear.h:2052
Definition: nuklear.h:3291
Definition: nuklear.h:452
Definition: nuklear.h:3003
short y
Definition: nuklear.h:456
NK_API void nk_end(struct nk_context *ctx)
NK_API int nk_menu_begin_symbol(struct nk_context *, const char *, enum nk_symbol_type, struct nk_vec2 size)
NK_API int nk_strfilter(const char *text, const char *regexp)
NK_API void nk_combobox_string(struct nk_context *, const char *items_separated_by_zeros, int *selected, int count, int item_height, struct nk_vec2 size)
nk_text_width_f width
Definition: nuklear.h:2367
char buffer[NK_MAX_NUMBER_BUFFER]
Definition: nuklear.h:3833
Definition: nuklear.h:494
void(* draw_begin)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:3317
NK_API char * nk_str_get(struct nk_str *)
NK_UINT8 nk_byte
Definition: nuklear.h:396
#define NK_CHART_MAX_SLOT
Definition: nuklear.h:3687
struct nk_text_undo_record undo_rec[NK_TEXTEDIT_UNDOSTATECOUNT]
Definition: nuklear.h:2706
unsigned short h
Definition: nuklear.h:2878
Definition: nuklear.h:2562
Definition: nuklear.h:460
Definition: nuklear.h:493
NK_API int nk_str_append_str_runes(struct nk_str *, const nk_rune *)
NK_API struct nk_color nk_rgba_fv(const float *rgba)
struct nk_config_stack_float floats
Definition: nuklear.h:3955
struct nk_style_button tab_maximize_button
Definition: nuklear.h:3570
#define NK_UNUSED(x)
Definition: nuklear.h:4053
int down
Definition: nuklear.h:3061
Definition: nuklear.h:3254
NK_INT16 nk_short
Definition: nuklear.h:397
short x
Definition: nuklear.h:2885
NK_API struct nk_vec2 nk_window_get_content_region_size(struct nk_context *)
Definition: nuklear.h:1878
NK_API struct nk_vec2 nk_window_get_content_region_max(struct nk_context *)
NK_API struct nk_rect nk_window_get_content_region(struct nk_context *)
NK_API int nk_select_image_label(struct nk_context *, struct nk_image, const char *, nk_flags align, int value)
float grow_factor
Definition: nuklear.h:2572
struct nk_vec2 uv
Definition: nuklear.h:979
nk_uint * scroll_pointer
Definition: nuklear.h:1684
Definition: nuklear.h:452
Definition: nuklear.h:471
NK_API void nk_layout_space_begin(struct nk_context *, enum nk_layout_format, float height, int widget_count)
unsigned int seq
Definition: nuklear.h:4043
Definition: nuklear.h:454
int select_end
Definition: nuklear.h:3837
nk_text_edit_mode
Definition: nuklear.h:2719
struct nk_config_stack_color colors
Definition: nuklear.h:3958
struct nk_edit_state edit
Definition: nuklear.h:3859
struct nk_color label_active
Definition: nuklear.h:3542
NK_API void nk_style_from_table(struct nk_context *, const struct nk_color *)
int sel_end
Definition: nuklear.h:3825
#define NK_UINT8
Definition: nuklear.h:340
struct nk_input input
Definition: nuklear.h:4007
NK_API int nk_button_label(struct nk_context *, const char *title)
#define NK_MAX(a, b)
Definition: nuklear.h:316
const struct nk_user_font * font
Definition: nuklear.h:3651
enum nk_button_behavior button_behavior
Definition: nuklear.h:4012
unsigned short table_size
Definition: nuklear.h:3864
NK_API int nk_button_text(struct nk_context *, const char *title, int len)
#define NK_CONTAINS(x, y, w, h, bx, by, bw, bh)
Definition: nuklear.h:4062
NK_API void nk_menubar_begin(struct nk_context *)
NK_API int nk_style_push_float(struct nk_context *, float *, float)
#define NK_PTR_TO_UINT(x)
Definition: nuklear.h:4083
#define NK_FONT_STACK_SIZE
Definition: nuklear.h:3902
NK_API int nk_combo_item_label(struct nk_context *, const char *, nk_flags alignment)
NK_API int nk_button_image_label(struct nk_context *, struct nk_image img, const char *, nk_flags text_alignment)
NK_API int nk_button_image_text(struct nk_context *, struct nk_image img, const char *, int, nk_flags alignment)
Definition: nuklear.h:673
Definition: nuklear.h:2698
NK_API void nk_color_hsv_fv(float *hsv_out, struct nk_color)
NK_API int nk_str_insert_str_char(struct nk_str *, int pos, const char *)
struct nk_vec2i points[1]
Definition: nuklear.h:2969
Definition: nuklear.h:2019
struct nk_vec2 padding
Definition: nuklear.h:3378
NK_API int nk_menu_begin_label(struct nk_context *, const char *, nk_flags align, struct nk_vec2 size)
unsigned char grabbed
Definition: nuklear.h:3056
NK_API void nk_color_hsva_f(float *out_h, float *out_s, float *out_v, float *out_a, struct nk_color)
unsigned char mode
Definition: nuklear.h:3827
NK_API int nk_style_pop_flags(struct nk_context *)
NK_API int nk_button_symbol_text_styled(struct nk_context *, const struct nk_style_button *, enum nk_symbol_type, const char *, int, nk_flags alignment)
NK_API struct nk_color nk_rgb_hex(const char *rgb)
struct nk_style_item hover
Definition: nuklear.h:3535
nk_symbol_type
Definition: nuklear.h:489
NK_API struct nk_color nk_rgb_bv(const nk_byte *rgb)
NK_API int nk_str_insert_str_utf8(struct nk_str *, int pos, const char *)
struct nk_allocator pool
Definition: nuklear.h:2566
NK_API struct nk_image nk_subimage_id(int, unsigned short w, unsigned short h, struct nk_rect sub_region)
struct nk_color text_background
Definition: nuklear.h:3306
short cy
Definition: nuklear.h:2943
Definition: nuklear.h:687
NK_API void nk_plot_function(struct nk_context *, enum nk_chart_type, void *userdata, float(*value_getter)(void *user, int index), int count, int offset)
NK_API nk_rune nk_str_rune_at(const struct nk_str *, int pos)
NK_API int nk_style_pop_font(struct nk_context *)
struct nk_style_item hover
Definition: nuklear.h:3294
nk_command_clipping
Definition: nuklear.h:3002
tuple output
Definition: gtest_output_test.py:321
Definition: nuklear.h:3064
int columns
Definition: nuklear.h:3737
unsigned short r
Definition: nuklear.h:2935
int text_len
Definition: nuklear.h:3067
NK_INT32 nk_int
Definition: nuklear.h:399
NK_API int nk_tree_state_push(struct nk_context *, enum nk_tree_type, const char *title, enum nk_collapse_states *state)
float border
Definition: nuklear.h:3480
NK_API void nk_input_unicode(struct nk_context *, nk_rune)
Definition: nuklear.h:698
NK_API void nk_textedit_redo(struct nk_text_edit *)
NK_API void nk_menu_close(struct nk_context *)
Definition: nuklear.h:472
NK_API struct nk_vec2 nk_rect_size(struct nk_rect)
Definition: nuklear.h:671
struct nk_style_item background
Definition: nuklear.h:3521
NK_API void nk_str_init(struct nk_str *, const struct nk_allocator *, nk_size size)
NK_API struct nk_image nk_image_id(int)
short y
Definition: nuklear.h:2885
struct nk_color color
Definition: nuklear.h:2938
Definition: nuklear.h:3727
NK_API int nk_combo_begin_image(struct nk_context *, struct nk_image img, struct nk_vec2 size)
Definition: nuklear.h:2821
#define nk_vec2_len_sqr(a)
Definition: nuklear.h:4067
struct nk_style_button inc_button
Definition: nuklear.h:3510
struct nk_command header
Definition: nuklear.h:2918
Definition: nuklear.h:2056
Definition: nuklear.h:3246
NK_API void nk_color_d(double *r, double *g, double *b, double *a, struct nk_color)
NK_API void nk_combo_end(struct nk_context *)
Definition: nuklear.h:2834
NK_API int nk_propertyi(struct nk_context *, const char *name, int min, int val, int max, int step, float inc_per_pixel)
Definition: nuklear.h:3694
nk_size calls
Definition: nuklear.h:2578
NK_API void nk_input_char(struct nk_context *, char)
Definition: nuklear.h:2882
NK_API void nk_color_dv(double *rgba_out, struct nk_color)
struct nk_page_element win[1]
Definition: nuklear.h:3991
#define NK_INTERSECT(x0, y0, w0, h0, x1, y1, w1, h1)
Definition: nuklear.h:4060
NK_API struct nk_vec2 nk_vec2v(const float *xy)
NK_API int nk_tooltip_begin(struct nk_context *, float width)
void(* draw_end)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:3318
NK_API struct nk_rect nk_recti(int x, int y, int w, int h)
NK_API struct nk_panel * nk_window_get_panel(struct nk_context *)
struct nk_vec2 menu_padding
Definition: nuklear.h:3646
struct nk_color label_normal
Definition: nuklear.h:3496
nk_size offset
Definition: nuklear.h:2559
nk_show_states
Definition: nuklear.h:470
struct nk_color color
Definition: nuklear.h:3260
struct nk_style_item pressed
Definition: nuklear.h:3325
NK_API int nk_style_pop_color(struct nk_context *)
NK_API struct nk_color nk_rgba_iv(const int *rgba)
unsigned char single_line
Definition: nuklear.h:3828
struct nk_color selected_hover
Definition: nuklear.h:3475
NK_API void nk_chart_end(struct nk_context *)
short x
Definition: nuklear.h:2927
struct nk_command_buffer * buffer
Definition: nuklear.h:3776
float a
Definition: nuklear.h:454
struct nk_color menu_border_color
Definition: nuklear.h:3623
NK_API int nk_menu_item_symbol_label(struct nk_context *, enum nk_symbol_type, const char *, nk_flags alignment)
Definition: nuklear.h:465
Definition: nuklear.h:1745
Definition: nuklear.h:3723
NK_API int nk_combo_begin_symbol_label(struct nk_context *, const char *selected, enum nk_symbol_type, struct nk_vec2 size)
Definition: nuklear.h:472
#define NK_ALIGN_PTR_BACK(x, mask)
Definition: nuklear.h:4094
NK_API int nk_style_push_vec2(struct nk_context *, struct nk_vec2 *, struct nk_vec2)
nk_heading
Definition: nuklear.h:465
#define nk_vec2_muls(a, t)
Definition: nuklear.h:4068
nk_style_colors
Definition: nuklear.h:2017
NK_API struct nk_vec2 nk_window_get_content_region_min(struct nk_context *)
NK_API int nk_menu_begin_text(struct nk_context *, const char *title, int title_len, nk_flags align, struct nk_vec2 size)
struct nk_color background
Definition: nuklear.h:2993
struct nk_vec2i end
Definition: nuklear.h:2868
nk_handle userdata
Definition: nuklear.h:3011
Definition: nuklear.h:491
NK_API struct nk_rect nk_rectiv(const int *xywh)
unsigned short h
Definition: nuklear.h:461
struct nk_color border_color
Definition: nuklear.h:3566
NK_API struct nk_vec2 nk_widget_size(struct nk_context *)
NK_API void nk_layout_row_push(struct nk_context *, float value)
nk_flags text_alignment
Definition: nuklear.h:3307